MySQL Create login error ERROR1045 (28000)

Source: Internet
Author: User
Tags mysql create

Recently, a user was created. However, an error message appears when you log in:

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)


Looked up the internet and found the cause of the problem. When the database is installed, there is an anonymous user who is empty, and this user is empty it can match any character . As (fourth):


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/68/wKioL1b-U2WQe3K4AAAzsU4IWcg027.png "title=" 2016-04-01_184938.png "alt=" Wkiol1b-u2wqe3k4aaazsu4iwcg027.png "/>


And the user I created is:

Mysql> Grant all on itcase.* to ' test ' @ ' percent ' identified by ' 123456 ';


The error 1045 (280000) prompt appears when you log on. The wildcard character% in the Create command can match all characters .

The problem is clear when I enter the login command:

c:\users\administrator>mysql-utest-p123456

The system will look for the matching field, the user test his host is defined as%, any of the host fields can be. To match the user field, then test matches to the fourth field with a null username. This means that we are logged in with an anonymous user, not the test user we want, and the password validation error. So can't login;


The reason is found, the solution is to delete the anonymous user on the line. Anonymous users are self-given by the system, and they do not have a password, you can easily log in; From a security perspective, deleting anonymous users can also improve the security of your database.


Log in to MySQL with the root user;

mysql> use MySQL;

Database Changed

Mysql>delete from user where user= ';
Query OK, 2 rows affected (0.17 sec)

Mysql>exit


Ok! To resolve this issue.

MySQL Create login error ERROR1045 (28000)

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.