Reputation: 1
<?php
$dbh=mysql_connect('187.0.0.0','abcd','1234') or die(mysql_error());
if($dbh)
{
echo "server connected";
}
$db=mysql_select_db('demo') or die(mysql_error());
if($db)
{
echo "database connected";
}
?>
I used this code on another server to check the connectivity but I'm getting an error
Host 'mail.hosting1001.in' is not allowed to connect to this MySQL server
Upvotes: 0
Views: 61
Reputation: 44831
The server has to allow remote connections by the user in question. Use the GRANT
syntax to give your user remote permissions (but limit those permissions to the IP address from which you are making the remote connection, assuming it's a fixed address).
Even better, as feeela suggested in the comments: open a secure tunnel between the machines so that you can connect as if you were connecting to the local machine.
Also, please don't use mysql_*
; the mysql_*
functions are outdated, deprecated, and insecure. Use MySQLi
or PDO
instead.
Upvotes: 2