Friday, February 26, 2010

How to resolve mysql_connect() Error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES)

Possible root cause for this problem is proper priviliges not assigned to the particular user. So providing proper previliges will solve this issue.

$grant all priviliges on "Database_Name" to "username@localhost" identified by "password"

If the mysql resides in the same server then we will use "user_name@localhost", to identify the user and

If the mysql resides in different server then we will use "user_name@%" to identify the user. 

To check whether database is connecting with the user use the following command

$ mysql -u username -p

Enter the password:

MySQL connects with the server.

Thus the error is resolved

Note :

$ represents command should be entered in the terminal

Comment me if you need further clarifications

No comments:

Post a Comment