How to retrieve the root login password of MySQL database in CentOS system

I forgot my mysql login password in CentOS, what should I do? We can use the safe mode to change the password.

Stop the mysql database:

#service mysqld stop

Continue to enter in the CentOS system:

#mysql -udebian-sys-maint -p

The password can be directly typed in and press enter.

Reset the password in CentOS system:

mysql> update mysql.user set password=password("123456") where user="root";

Refresh permissions

mysql>flush privileges;

drop out

mysql>exit;

Start mysql and continue the previous login actions.

# service mysqld start

# mysql -u root –p

Guess you like

Origin blog.csdn.net/ichen820/article/details/114873628