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