centOS下mysql5.7后忘记密码后修改密码的方法

Linux命令:
centOS下mysql5.7后忘记密码后修改密码的方法:
su
进入root账户下,输入root账户密码:
vim /etc/my.cnf
修改加上:
skip-grant-tables
保存,按esc后
wq:
执行
source /etc/my.cnf
重启后
su
进入root账户,输入
mysql
直接登录MySQL数据库,然后
use mysql
执行
update user set authentication_string=password(‘password’) where user=‘root’;
MySQL5.7后密码要求8~16位,建议不要使用root作为密码;
重登
mysql -uroot -p
记得将
vim /etc/my.cnf

skip-grant-tables删除

猜你喜欢

转载自blog.csdn.net/shengongbao114/article/details/84326377