What should I do if I forget my login password?

Interview question case: What to do if the administrator root@'locahost' is lost.

--Skip-grant-tables (turn off authorization table login)
--skip-networking (only local login and remote login off)

a. Shut down the database instance
/etc/init.d/mysqld stop

b. Start
mysqld_safe in special mode --skip-grant-tables --skip-networking &

c. Login to refresh the authorization table
[root@db01 data]# mysql
mysql> flush privilges;
d. Change the password
mysql> alter user root@'localhost' identified by '123';

e. Restart to normal mode
[root@db01 data]# /etc/init.d/mysqld restart

f. Log in to
mysql -uroot -p123 based on the password just given

Guess you like

Origin blog.csdn.net/weixin_49629796/article/details/113762230