tags:

views:

147

answers:

4

hi,

I am trying to connect remote mysql i am having typical issue.

$conn = mysql_connect('xxx.xxx.xxx.xxx', 'username', 'password') or die(mysql_error());

Let my system host name is my.host.com and remote one is remote.host.com

I tryed using both IP xxx.xxx.xxx.xxx and remote.host.com it is saying that

Access denied for user 'username'@'my.host.com' (using password: YES)

Please help me out of this problem.

Thanks in advance.

A: 

Check if the password and username you specified are correct and if the user is setup for access in the database.

If that does not solve the issue, read http://dev.mysql.com/doc/refman/5.1/en/access-denied.html

Gordon
i am using hostname as remote.host.com but it showing Access denied for user 'username'@'my.host.com' (using password: YES)
itsoft3g
The hostname is not your problem. Otherwise you would not get an Access Denied response from the server. Check User/Pass and GRANTs
Gordon
how to setup grant
itsoft3g
Like it says in the other answers. Where did you get the username and the password to the database from? Who owns the database server?
Gordon
+1  A: 

Did you grant the permissions of the user with the hostname?


GRANT ALL ON mydb.* TO 'someuser'@'somehost';

mmattax
i am using hostname as remote.host.com but it showing Access denied for user 'username'@'my.host.com' (using password: YES)
itsoft3g
The user must have permissions on that specific host, did you set that up?
mmattax
A: 

You'll need to permit access to the required client host from within MySQL.

See the GRANT command (specifically the "Global privileges" bit) for the specifics.

middaparka
i am using hostname as remote.host.com but it showing Access denied for user 'username'@'my.host.com' (using password: YES)
itsoft3g
You need to permit access from 'my.host.com'. (Incidentally, I presume it isn't saying 'my.host.com', but rather the specific host you're attempting to connect from.)
middaparka
how i can do that ? please help me
itsoft3g
I am accessing the remote server using WHM xml api. Can i grant from WHM ?
itsoft3g
This is basic setup stuff. If you have a management console of some sort, log in there. Look for database administration tools. If you have shell access to the machine, log in there. If in doubt, contact your server administrator/provider.
Pekka
A: 

Please read the The MySQL Access Privilege System chapter in the MySQL documentation:

Your identity is based on two pieces of information:
* The client host from which you connect
* Your MySQL user name
Identity checking is performed using the three user table scope columns (Host, User, and Password). The server accepts the connection only if the Host and User columns in some user table row match the client host name and user name and the client supplies the password specified in that row.
I.e. if your php script runs "on" my.host.com and connects to some remote MySQL server there must be an entry in the server's mysql.user table for [username, my.host.com, yourpassword] or the server will deny access.

VolkerK