0

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;

Lucas Famelli
  • 1,565
  • 2
  • 15
  • 23

3 Answers3

1

Seems to me like a firewall issue. You should check if the machine hosting the MySQL server allows connection on the port 3306 from external IPs as well.

Sabeen Malik
  • 10,816
  • 4
  • 33
  • 50
1

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.

Kibbee
  • 65,369
  • 27
  • 142
  • 182
0

Check if the server you have to connect to has the firewall open on the port you are trying to connect... default port is 3306 you can use

mysqladmin -h localhost

to see check what is the port mysql is using

SimonQuest
  • 662
  • 1
  • 5
  • 17