Centos 7.2 mysql5.7 solve the root user forgets the password

1. The first step is to reset the password of password authentication process is skipped MySQL, as follows:

#vim /etc/my.cnf (Note: the windows are modified my.ini)

In the document search target mysqld [mysqld] text segment:
/ mysqld (the command is entered directly in the edit state vim searchable text)

In [mysqld] Add any line behind the "skip-grant-tables" to skip the password authentication process, as shown below:

Save the document and exit

2. Next, we start mysql

 

 

 

3. reset the password for the root user

Enter mysqlinto the mysql command-line interface:

 
1.jpg


reset Password:

 

update mysql.user set authentication_string = password('new_password') where user = 'root';
flush privileges;

Here the root account has been reset to the new password.

4. Edit my.cnf, remove content just added, and then restart MySQL. We're done!

Note:  new_passwordon behalf of the root user's new password, you need according to their actual situation to replace

Guess you like

Origin www.cnblogs.com/Dearmyh/p/11704782.html