Jump to content

Cannot get mysql_connect to talk to remote host...


sunfire

Recommended Posts

Hello,

I have been hitting my head on my desk for the last few hours. I'm trying to connect to a remote MySQL database. I can connect to the one on the localhost but not the remote one. I keep getting the error.

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

I changed the error text of the user and host. The problem is "mysql.mydb.com" is not the server name/host I'm specifting in my php code. It's the FQDN of the localhost.

 

$servername='dbmysql.mydb.com';
$dbusername='dbuser';
$dbpassword='PasswordTextRemoved';
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());

 

What am I doing wrong, thanks!

Tom

 

The problem is "mysql.mydb.com" is not the server name/host I'm specifting in my php code.

 

it sure looks like that is the server name/host that you are specifying in your code:

 

$servername='dbmysql.mydb.com';
$dbusername='dbuser';
$dbpassword='PasswordTextRemoved';
$link=mysql_connect ("$servername","$dbuser","$dbpassword");

I can access the localhost mysql database, but can not get to the remote mysql database. I have used NaviCat to verify that the user name and password work for the remote mysql database. So I do not think it's a permissions thing.

 

// localhost = mysql.mydb.com
$servername='localhost'; // works!

// remote db = dbmysql.mydb.com
$servername='dbmysql.mydb.com'; // does not work I get the error

 

Thanks,

tom

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.