1. 程式人生 > 其它 >解決MySQL ERROR 1045 (28000)

解決MySQL ERROR 1045 (28000)

技術標籤:資料庫

在使用navicat連線資料庫時,報錯資訊:MySQL ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES),

解決方法:

1、修改mysql的登入設定

vim /etc/my.cnf

並在[mysqld]下面新增一句:skip-grant-tables(跳過資料庫許可權驗證)
在這裡插入圖片描述

儲存並退出

重啟mysql並修改密碼

/etc/init.d/mysqld restart

進入mysql

[[email protected]_0_17_centos ~]# mysql
use mysql

更新密碼

#mysql5.7之前版本
update user set password=password('root') where user='root';
#mysql5.7版本
update user set authentication_string=password('root') where user='root';

flush privileges;
3、再次修改 /etc/my.cnf

將skip-grant-tables 刪除 儲存退出

4、再次啟動mysql就可以正常使用
service mysqld start