I accidentally deleted the MySQL root Account by changing the root password and restoring the MySQL root User. What should I do? "And" I lost my root password? If this problem occurs, why do you need to back up data, reinstall MySQL, and restore all database files? What should we do? Now we can find a better way for you.
Change the root password and restore the root user of the mysql tutorial
I accidentally deleted the root account of mysql. What should I do? "And" I lost my root password? If this problem is encountered, why do you need to back up data, reinstall mysql, and restore all database tutorial files? What should we do? Now we can find a better way for you.
1. Stop mysql,
2. Server Permissions
C: www.bKjia.c0mbinmysqld-nt.exe -- skip-grant-tables
Where c: www. bKjia. c0m is mysql 'instalation directory.
For linux, run the following command:
/Usr/local/mysql/bin/mysqld_safe -- skip-grant-tables -- user = root -- skip-networking
3. Connect to the server and use the exsisting account (root or some otherif root accounts are deleted ).
C: www.bKjia.c0mbinmysql.exe-u user
Or
/Usr/local/mysql/bin/mysql-u user
4. Change the mysql query Password
Update mysql. user set password = password ('newpwd') where user = 'root ';
Or recreating user:
Create user root identified by password 'newpwd ';
Grant all privileges on *. * to 'root' @ 'localhost' identified by 'newpwd' with grant option max_queries_per_hour 0 max_connections_per_hour 0 max_updates_per_hour 0 max_user_connections 0;
5. Refresh Permissions
Flush privileges;
6. Restart the server
OK. You can retrieve the mysql root Password.