MySQL connection ERROR: ERROR 1045 (28000): Access denied for user

Source: Internet
Author: User

MySQL connection error:

ERROR 1045 (28000): Access denied for user

----------------------------------------------------------------------------------

1. Add a user

Shell> mysql

Mysql> use mysql

Mysql> grant all privileges on *. * to 'test' identified by 'test' with grant option;

Mysql> flush privileges;

[You can also use the following two methods to create a user]

------------------------

$1 directly operate the mysql. user table;

$2 use the DDL language,

User Defined: create user test identified by 'test ';

Delete user: drop user test

------------------------

2. Log On with test (always unable to connect)

Shell> mysql-u test-p

ERROR 1045 (28000): Access denied for user 'test' @ 'localhost' (using password: YES)

3. Check the user table and we will find that the user field in the user table has NULL

Mysql> select host, user from user;

+ ------------------ + ------ +

| Host | user |

+ ------------------ + ------ +

| % | Test |

| Localhost |

| Localhost | root |

| Test.saeg.com.cn |

| Test.saeg.com.cn | root |

+ ------------------ + ------ +

5 rows in set (0.00 sec)

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

(4.1) delete from user where user is NULL

4.2) update user set user = 'test' where user is NULL

Problem Solving

In addition, [my system is RHEL4.0]

1. mysql configuration file my-*. cnf

/Usr/local/mysql/

2. initialize the database

/Usr/bin/mysql_install_db

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.