I. Restoring the mysql password in Linux
Service mysqld stopmysqld_safe -- skip-grant-tables; ctrl + z pause # Start mysql service mysql-u root-p in safe mode # Use root User Login Without Password ): mysql> use mysql; mysql> update user set password = password ('new password') where user = 'root'; mysql> flush privileges;
Log on to shell again and use the new password!
Ii. mysql password recovery in Windows
1. net stop mysql
2. Switch to the mysql installation directory \ bin.
3. mysqld-nt -- skip-grand-tables
4. Open a new cmd window and enter mysql-u root-p # login without a password
5. update user set password = password ('new password') where user = 'root ';
3. Enable mysql remote Logon
Mysql> grant all privileges on *. * to 'root' @ '%' identified by 'remote password'; # privileges can be omitted
Mysql> flush privileges;
Parameter description:
All: authorize all operation commands to add, delete, modify, and query)
*. *: Authorize all databases and tables.
%: Allow all IP addresses to access mysql
Flush privileges;: refresh the authorization table
Check whether it is enabled. The following message is displayed, indicating that all remote logins are allowed.
Mysql> select host, user, password from user;
| % | Root | * 4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
4. Other commands
Revoke all privileges on *. * from 'root' @ '%'; # revoke the permissions granted to the user;
Show grants;: View Current User Permissions
Show grants for user @ localhost;: view other User Permissions
This article is from the "Linux popular technology" blog, please be sure to keep this source http://going.blog.51cto.com/7876557/1294746