MySQL-忘记密码

1. 停止数据库 
[root@db01 data]# /etc/init.d/mysqld stop

2. 使用维护模式启动数据库
[root@db01 data]# mysqld_safe --skip-grant-tables --skip-networking &

3. 无密码登录并修改密码
shell> mysql 
mysql> flush privileges;    /*手工加载授权表*/
mysql> alter user root@'localhost' identified  by '123456';

4. 重启数据库到正常模式
[root@db01 data]# systemctl restart mysqld
posted @ 2023-05-06 17:33  Enzo_Ocean  阅读(10)  评论(0编辑  收藏  举报