When practicing the MySQL statement, delete all the users in the database using Delete, which also includes the root user. And the flush privileges was found, and it was not possible to log in again. For this we will reset the root account and root password. The following are the steps:
To delete a user action:
mysql> Delete frommysql.user; Delete all users mysql> flushprivileges;
First, disconnect all links associated with the database to prevent data loss when the database restarts.
[[Email protected] ~]# service mysqld stop
To modify a database configuration file
[Email protected] ~]# VIM/ETC/MY.CNF
Content under [MySQL] in the configuration file
in the [MySQL]
in the next line, add the Skip-grant-tables "
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/FC/wKioL1fnJ9rTsEHnAAAo_-skRVE661.png-wh_500x0-wm_3 -wmp_4-s_2194652098.png "title=" If.png "alt=" Wkiol1fnj9rtsehnaaao_-skrve661.png-wh_50 "/>
Save and exit, restart MySQL database
[Email protected]]# MySQL
Mysql> Insertinto Mysql.user (host, user, PASSWORD,SLL_CIPHER,X509_ISSUER,X509_SUBJEC) values (' localhost ', ' root ', Password (' 123456 '), ', ', ');
exit the database, then the mysql.cnf configuration file to make changes, delete the newly added row. Restart the database.
[Email protected] ~]# service mysqld restart
You can complete the addition of Mysqlroot users!
The second method does not modify the MySQL configuration file;
Service mysqld stop//stop MySQL database service mysqld_safe--skip-grant-tables--skip-networking
In addition terminal
Mysqlmysql> Insertinto Mysql.user (host, user, PASSWORD,SLL_CIPHER,X509_ISSUER,X509_SUBJEC) values (' localhost ', ' Root ', password (' 123456 '), ', ');
You can complete the addition of the database root user!
This article is from the "Heart Empty Diffuse" blog, please be sure to keep this source http://aiyouwei.blog.51cto.com/11705634/1856266
How to reset the root account and password by mistakenly deleting the user in MySQL