使用root用戶登錄mysql數據庫出現如下報錯ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)。
解決方案:
1.執行命令:service mysqld stop;停止mysql服務
2.加參數啟動執行命令mysqld_safe --skip-grant-tables (注意:執行后會卡在當前終端上)
3.在開打開一個終端mysql -u root ;就可以登陸數據庫了
4.執行命令:use mysql;切換數據庫
5.執行命令:update user set password=password("123456") where user="root"; 更改root密碼
6.flush privileges; 配置參數生效
7.退出數據庫;exit;
8.service mysqld start ;啟動數據庫