Jump to content

How to connect mysql server in other web server


klpang

Recommended Posts

Dear All,

    I have a website need to connect a database in other webserver. In the scirpt, i put $sql = mysql_connect("xxx.xxx.xxx.xxx", "root", "xyzpassword") or die(mysql_error()) and the result is Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10061). The webserver is in linux platfrom, at first i taught that is block by firewall. when i stop firewall service, the progarm still prompt same result. please advise.

 

 

 

MySQL is probably rejecting external connections. This is something you will have to modify with the MySQL installation. Alternatively if this isn't the problem it's probably the MySQL user you have created.

GRANT ALL ON *.* FOR 'root'@'%'

 

HOWEVER, this is a warning, you are allowing external access to MySQL from the root user, this user has privileges to EVERYTHING, and thus is not a very clever nor secure thing to do.

 

There's a --skip-networking option in the my.cnf file too -- in which case the grant won't help, AFAIK....  but you can troubleshoot by allowing *, but without ALL.  Select privileges alone will allow you to log the IP.

Thanks a lot. But still can't connect to database. already add port 3306 (tcp/udp) in iptables, still the same result.  Is there any way to connect.

 

For example

mysql_connect(publicaddress/domainname, "root", "password");

 

Result

Can't connect to MySQL server on 'publicaddress/domainname' (10061)

 

 

Please advise.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.