Hi,
I need to connect to a remote MySQL database and have created the following connection code:
<?php
/* Set Variables */
$host="myipaddress";
$db="mydbname";
$username="dbuser";
$pass="mypass";
/* Attempt to connect */
$mysqli=new mysqli($host,$username,$pass,$db);
if (mysqli_connect_error()){
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
echo 'Success... ' . $mysqli->host_info . "\n";
$mysqli->close();
}
?>
For security reasons, I've not provided the actual variable values. When I run this on my development system, I receive
Connect Error (2003) Can't connect to MySQL server on 'myipaddress' (10061)
My PHP is a bit rusty, can someone identify where my code is faulty? Note that dbuser has select, insert and update privileges on the database name set as the variable.
Thanks, Sid
Edit I made changes to my.cnf and restarted mysql. I now receive access denied for user 'dbuser'@'mycurrenthostname' (using password YES). When I use mysql -u dbuser -p from command line, I can login. I granted insert, update and select to dbuser with host '%' so that dbuser could connect from anywhere.
I've read the MySQL Reference guide about this error, but am still stuck. Is there a problem with my code, now that my.cnf has been fixed?