Phenomenon: After modifying the root password, quit MySQL, restart the MySQL service, and then want to use the new password to log on to MySQL, found not to go up.
One, the reason to encounter this problem is that when the user changes the password is not using the password () function to encrypt the password. As follows:
mysql> Update user set password= ' [email protected] ' where user= ' root ';
Query OK, 3 Rows Affected (0.00 sec)
Rows Matched:3 Changed:3 warnings:0
mysql> quit
# mysql-u Root-p
Enter Password: ********
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
using SELECT queries The user table in the MySQL library can be found in the user table, where the passwords are in encrypted form.
mysql> SELECT * from user where user= "root";
....
| localhost | Root | *a00c34073a26b40ab4307650bfb9309d6bfa6999 | Y | Y | Y | Y
....
If you specify ' Set password= ' [email protected] ', MySQL will assume that ' [email protected] ' is an encrypted string, so the encryption string corresponds to the
The password is naturally not ' [email protected] ', but a value for another location.
The correct command to change the root password should be
mysql> Update user set password=password (' [email protected] ') where user= ' root ';
Two, now know the reason. But we can't go to the database, what to do. here's how to fix it:
1. Locate the current database process and kill it
2, go to the MySQL installation directory, go to the bin directory, execute mysqld_safe--skip-grant-tables (default installation path/usr/local/mysql/bin)
After this step, the MySQL service will be started in a way that ignores user permissions, and can use MySQL to login without a password. Available via PS aux | grep MySQL View service has started
3, reopen a console, execute the ' mysql ' command again, this time can login without password
4. Re-modify the password with the correct command
5, login with password, OK
6, it is best to use the following command to refresh the system permissions (otherwise others can login without password)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
MySQL cannot log on again after modifying password