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