编程爱好者之家

centos7重置mysql密码

2018-08-13 22:19:36 405

1.  vi /etc/my.cnf,在[mysqld]中添加

skip-grant-tables

image.png

2.重启mysql,然后用无密码登录

systemctl restart mysqld

mysql -uroot -p (直接点击回车,密码为空)

3.进入数据库更改密码,刷新权限

use mysql;
update user set authentication_string=password('新密码') where user='root';
flush privileges;

4.最后删除1中添加的'skip-grant-tables',然后重启mysql即可

同类文章