Modify the mysql root user password (forgot password)

  1. vi /etc/my.cnf, add [mysqld] in

skip-grant-tables

E.g:

[mysqld]
skip-grant-tables
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

  1. Restart mysql

service mysql restart

  1. Use of non-logged-on user password

mysql -uroot -p (click on the Enter password is blank)

  1. Select Database

use mysql;

  1. Changing the root password

update user set authentication_string=password('123456') where user='root';

6. Refresh rights

flush privileges;

7. Quit

exit;

8. Delete the first increase in a configuration information

skip-grant-tables

9. Restart mysql

service mysql restart

Guess you like

Origin www.cnblogs.com/kevliudm/p/11025509.html