1,修改/etc/my.cnf配置,繞過權限判斷
[mysqld]
skip-grant-tables
2,重啟mysql,進入控制台(此時已無需密碼),先刷新權限。記住先別忙着就操作權限和密碼,先運行以下語句,否則你的操作依然會繼續報錯。
flush privileges;
3,然后重置root密碼,或者給root添加權限。
update mysql.user set authentication_string=password(‘新密碼‘) where user=‘root‘;//mysql 5.7
grant all privileges on *.* to root@‘localhost‘;
4,最后還原一下my.cnf,然后重啟。
root@localhost問題