2. How to solve the forgotten MySQL administrator password?

How to solve the forgotten MySQL administrator password?

1.#关闭数据库
[root@mysql01 ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 

2.#启动数据库到维护模式
[root@mysql01 ~]# mysqld_safe --skip-grant-tables --skip-networking &

3.#登录并修改密码
[root@mysql01 ~]# mysql 
mysql> flush privileges;
mysql> alter user root@'localhost' identified by '1';
Query OK, 0 rows affected (0.01 sec)

4.#关闭数据库,正常启动验证
[root@mysql01 ~]# pkill mysqld

Guess you like

Origin blog.csdn.net/weixin_43357497/article/details/112447244