MySQL cannot log on again after modifying password

Source: Internet
Author: User
Tags mysql view

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.