Jump to content

How do I Connect to remote mysql database


beachcomber

Recommended Posts

Hi,

 

I have a requirement to allow remote access to my mysql database.

 

I\'ve read a million threads on this subject and none of them seem to give clear instructions on how to do this.

 

I tried the following code.

 

where $db_hostname is the ip address of the server.

 

 




 $db_hostname= xxx.xxx.xxx.xxx 

 $db_username="XXXXX"; 

 $db_password="YYYYYY";







if(!mysql_connect("$db_hostname","$db_username","$db_password"))

{

echo "SQL_ERROR: Cannot connect to Database: $db_name<br>"; exit();

}



else



{



echo "Connection successful";



}



 

 

This produced the following set of errors.

 

Warning: Access denied for user: \'XXXXXX@ns0.ennsol.co.uk\' (Using password: YES) in /www/html/_codebase/connect/remote_connect.php on line 22

 

Warning: MySQL Connection Failed: Access denied for user: \'XXXXX@ns0.ennsol.co.uk\' (Using password: YES) in /home/virtual/site97/fst/var/www/html/_codebase/connect/remote_connect.php on line 22

SQL_ERROR: Cannot connect to Database: testbed_ennsol_co_uk

 

If I use localhost as the db_hostname I connect without any problems. What do I have to do to allow a remote connection to the database?

 

Is this a coding issue or is there a setting on the server that needs to be changed?

 

 

All help and suggestion greatfully received!

 

Rob

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.