Connection error occurred in MySQL: Error 1045 (28000): Access denied for user

Source: Internet
Author: User

A connection error occurred in MySQL:

ERROR 1045 (28000): Access denied for user

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

1. Add User

Shell>mysql

Mysql>use MySQL

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

Mysql>flush privileges;

[You can also use the following two ways to create users]

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

Direct Operation mysql.user this table;

$ $ Use DDL language,

Define User: Create user test identified by ' test ';

Delete User: Drop user test

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

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

Shell>mysql-u test-p

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

3. View the user table, 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 value of NULL in User.user 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

Another: [My system is RHEL4.0]

1.mysql configuration file My-*.cnf

/usr/local/mysql/

2. Initializing 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.