Access denied for user 'root'@'localhost' (using password: YES) 數據庫密碼正確,沒有權限

數據庫密碼輸入正確,卻沒有權限登陸解決方法:

1.輸入vim /etc/my.cnf (數據庫配置文件),在[mysqld]下面添加 skip-grant-tables 表示允許無密碼登陸,輸入:wq,保存退出

2. 重啓mysql

service mysql stop

service mysql start

3.輸入mysql -uroot -p 回車  不用輸入密碼,登陸:

 4.輸入 set password for 'root'@'localhost'=password('123456'); 重新設置密碼

5.報的無效錯誤,所以不能直接修改

 

6.換種修改方式:直接修改系統user表裏面的密碼

use mysql;

show tables;

然後查看錶結構:show columns from user;

mysql的密碼存放在 authentication_string字段上面,mysql有的版本密碼字段直接是password,需要仔細看。

7.更新密碼: update user set authentication_string=password("root1234") where user='root';

8.刷新表 flush privileges

9.然後按照步驟一刪除 配置中的 skip-grant-tables,重啓mysql即可。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章