mysql password forgot to change

Forgetting the password of mysql is a bad thing. Usually, we will remember the password or save it in the document to avoid forgetting it. If you forget the password, you can refer to the following method to change it. This operation requires restarting mysql.

First, we insert a line of configuration under the [mysqld] option in the my.cnf file: skip - grant - tables to skip password authentication.

 


Next restart mysql

service  mysqld restart

After a reboot, logging in with mysql -uroot will no longer require a password.

 

After entering the database management terminal, use the following sql to change the password of the root account (of course, you can also change the passwords of other users, if you do not need to log in with root.)

mysql> USE mysql;mysql> UPDATE user SET Password = password (‘新密码’) WHERE User = root;mysql> flush privileges ;mysql> quit

After the change is complete, delete or comment the skip - grant - tables configuration in the my.cnf document and then restart mysql.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324996258&siteId=291194637