linux 忘记mysql用户root密码 解决方案
1.vim /etc/my.cnf
[mysqld]
skip-grant-tables ##追加此行,跳过权限表,
2.重启mysql
systemctl restart mysqld
3.mysql 登陆mysql
mysql> use mysql;
mysql> update user set authentication_string=password ( 'root' ) where user = 'root' ;
或者
mysql> update mysql.user set authentication_string='root' where user='root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> flush privileges;
mysql> quit
4.恢复配置文件my.cnf
vim /etc/my.cnf
[mysqld]
skip-grant-tables ##去掉此行,继续校验权限表,
5.重启mysql
systemctl restart mysqld