The MySQL password is correct but cannot be logged on locally.

Source: Internet
Author: User

The MySQL password is correct but cannot be logged on locally.

The MySQL root Password is correct, but you cannot log on to MySQL locally.

Copy codeThe Code is as follows:
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES)

Later, the user table in the mysql database was found to be missing a data item whose root points to host: localhost, and only one data item whose root points to host: host Name, therefore, you cannot use the root account to log on to MySQL.

In summary, the root account does not have the account information for accessing the localhost host, resulting in local login failure.

The simulated test is as follows:

So how can I recover the root login?

Here is a record of today's Tangle:

Kill the MySQL process and add it to the mysql startup parameters.

Copy codeThe Code is as follows: -- skip-grant-tables

You can log on to mysql without a password.

Of course, we must also repair the lost data items of the root account.

There are two solutions:

First, the root account has three records at the beginning, including the root account's localhost, hostname, and 127.0.0.1 account data. We can update the host to the localhost of the other two items.
The second method is to directly insert a record, and the host is localhost.

To sum up, even if the root host contains the host name, 127.0.0.1 still cannot be logged on normally. Therefore, you must have the host of localhost.

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.