Mysql local super administrator password forgotten

What should I do if I forget the mysql local super administrator password?

The root password exists: /server/3306/data/mysql/user.MYD

1. Close the remote network—>Close the tcp/ip connection protocol, there is no port number, and only the socket mode is reserved. Single user mode-
skip-networking
2. Turn off the authentication function, do not load the authorization table, and do not verify.
–Skip-grant-tables

Solution:
1. Close the database normally

service mysqld stop

2. Start to single-user mode
Start in safe mode, do not load the tcp/ip protocol and authorization table, and run the database in the background.

# mysqld_safe --skip-networking --skip-grant-tables &

service mysqld start --skip-networking --skip-grant-tables

3. No password to enter the database

#mysql

flush privileges; The authorization table is not loaded, and the passwords below cannot be modified.

alter user root@‘localhost’ identified by ‘123’;

4. Restart the database to normal mode

service mysqld restart

Guess you like

Origin blog.csdn.net/weixin_45320660/article/details/107138094