Probably something basic I'm missing, but I'm unable to connect to a remote MySQL server from command-line PHP. Using Latest LSWS configured with suPHP.
Running
#php test_mysql.php
<?php
$username = "myuser";
$password = "123456";
$hostname = "my.remotesql.com";
$link = mysql_connect($hostname, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
Returns this error:
Warning: mysql_connect(): Access denied for user 'myuser'@'hostname.com' (using password: YES)
The error references the server hostname where the script is run rather than the remote sql host in $hostname.
I tried adding mysql.default_host to php.ini -- no help. Also, granted permissions on the sql server.
FWIW, I am trying to make MailWatch work with a remote db server. MailWatch runs as root outside of web space.
Running
#php test_mysql.php
<?php
$username = "myuser";
$password = "123456";
$hostname = "my.remotesql.com";
$link = mysql_connect($hostname, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
Returns this error:
Warning: mysql_connect(): Access denied for user 'myuser'@'hostname.com' (using password: YES)
The error references the server hostname where the script is run rather than the remote sql host in $hostname.
I tried adding mysql.default_host to php.ini -- no help. Also, granted permissions on the sql server.
FWIW, I am trying to make MailWatch work with a remote db server. MailWatch runs as root outside of web space.