Sunday, September 23, 2007

MySQL Error Number 1045 ( Access denied for user username@servername )

Recently I faced this error while logging in to MySQL Query Browser after installing MySQL Server.

The solution is as follows:

1. Server,username,password is stored in user table of a database named mysql. Login to the MySQL CommandLine Client and run the following query :
select host,user,password from mysql.user; (password is encripted)

2.Grant permision to the perticular user who wants to login by the following command.
GRANT ALL ON database.* TO
username@server_name IDENTIFIED BY password

e.g: GRANT ALL ON mysql.* TO
'root'@'localhost' IDENTIFIED BY '123india' ;
Query OK, 0 rows affected (0.00 sec)

NOTE: If you dont know the password just enter any password of your choice in the "GRANT ALL" command above.That will be your new password.

Any sort of suggestion or comment is welcome.