Search code examples
phpmysqlconnectionremote-connection

Logging with a user in a remote MySQL database


How to log with a diferent user in a MYSQL remote database? Here's what I've done:

Logged as root in the MYSQL:

'create user 'user'@'%' IDENTIFIED BY 'password';
'grant select on *.* to 'user'@'%';

Then I setted a PHP script which connection is this one:

$con = mysql_pconnect("xxx.xx.xxx.xxx","user","password");
$selected = mysql_select_db("database",$con);

Aaaand it isn't working: I'm using LAMP on a cloud server, by the way;

Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'xxx.xx.xxx.xx' (10061) in D:\path\index.php on line 21

What am I doing wrong?

EDIT: Not a firewell issue;


Solution

  • You might want to check the MySQL documentation on this specific problem. If I had to guess, I would say that your MySQL server may be bound only to the local (127.0.0.1) address. To troubleshoot you should probably try connecting to the server using the command line MySQL client in order to get a better idea of why exactly the connection isn't being made.