Mysql error 1045 (28000): Access denied for user (using pass

Source: Internet
Author: User

Method 1: Recommended
ERROR Description: After a user is added to Mysql, the ERROR 1045 (28000): Access denied for user may occur during logon.

Cause analysis: the mysql. user table may contain records with empty users, for example:

Mysql> select host, user from user;
+ ------------------ + ------ +
| Host | user |
+ ------------------ + ------ +
| % | Test |
| Localhost |
| Localhost | root |
+ ------------------ + ------ +
3 rows in set (0.00 sec)

Solution: delete these empty users or update them to another user name.

Delete the value of user. user that is NULL or update NULL to test.

1) delete from user where user is NULL
2) update user set user = 'test' where user is NULL

Unexpected situation: if the above method does not work and empty users still appear, you can use the graphical user client to delete it.

Method 2: in linux
Opening Remarks: Solving LINUX problems is a pleasure. Of course, if you encounter problems, you will be given the opportunity to enjoy happiness.
This time we use Mandriva2008spring.
To build a project, you need to install MySql. In the past, MySql was installed smoothly. In particular, you only need to double-click the rmp package provided by MySql ~ However, I don't know when MYSQL ERROR 1045 (28000): Access denied for user (using password: YES) will cause a wide range of Access denial problems.
Baidu has a problem, and there is no ready-made solution. Only the problem can be found.
Step 1: skip the authorized table access and run the following command: mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking & (before that, of course, stop the mysql service first ).
Step 2: log on to mysql using mysql-uroot mysql.
Step 3: Access the user table in the mysql database. On my machine, mysql> select * from user;
Empty set (0.00 sec ). This shows that my mysql does not have any users that can be accessed. Once you understand the problem, it is easy to solve it.
Step 4: mysql> insert into user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'username', PASSWORD ('yourpassword '), 'y', 'y', 'y ');
Query OK, 1 row affected, 3 warnings (0.00 sec)
The returned result is successful. No problem. Hey ~~~ That's simple.
Step 5: Test and restart the mysql service. The logon succeeds !!!

Tip: the mysql database in the mysql system stores system data. For example, the user table here stores user information and access permissions. For example, if you want to create a database named mydb, if the database is managed by me, the db table in the mysql database will store relevant information. More nonsense.

The solution for windows is as follows:
However, if we use the VM management system to enable users with a large number of users, it seems that it is not a good solution.

I re-installed mysql, and then went to the virtual host, deleted one by one, and re-opened the database. before the operation, I had to back up the original data directory, and finally overwrite the space database.

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: 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.