linux 忘記mysql用戶root密碼 解決方案

1.vim /etc/my.cnf
[mysqld]
skip-grant-tables ##追加此行,跳過權限表,mysql

2.重啓mysql
systemctl restart mysqldsql

3.mysql 登錄mysql
mysql> use mysql;
mysql> UPDATE user SET Password = password ( 'zha123456' ) WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quitvim

4.恢復配置文件my.cnf
vim /etc/my.cnf
[mysqld]
skip-grant-tables ##去掉此行,繼續校驗權限表,ui

5.重啓mysql
systemctl restart mysqldrest

相關文章
相關標籤/搜索