Forgot your password resolve MySql

Description: mysql forget the password, how to do without being able to log in?

Environment: CentOS 7, databases: mysql 5.7

1. Stop the database (see first mysql service is running)

# Ps -ef | -i grep mysql // view the status of running mysql 
# service mysql stop

2, edit the mysql configuration files, configuration files directory: /etc/my.cnf

[mysqld] 
Skip -grant-// Skip the Tables Password

3, start mysql service, use no password to log into mysql

# service mysql start
# mysql -uroot -p

4, modify the database password

mysql> use mysql;     // use mysql database 
mysql> Update the mysql.user the SET authentication_string = password ( ' new password ' ) the WHERE the User = ' root ' ;         // change the root password 
mysql> flush privileges;         // refresh permission 
mysql > exit

5, delete the configuration file, add configuration parameters

grant--Skip the Tables // delete parameters 
: wq // save and exit

6, restarting the database

systemctl start  mysqld.service

7, using the new password to log back into the database OK

Guess you like

Origin www.cnblogs.com/ByteBeat/p/11300332.html