Page 1 of 1
Connecting from different host in different network.
Posted: Wed Jun 06, 2007 1:26 am
by jlising
Hello,
Is it possible to connect a php script to mysql server located to different network?
like for example, i have a script in
http://www.myphpserver.com and connect it to
http://www.mymysqlserver.com.
If possible, what are the procedures and precautions should i follow.
Thanks!
Posted: Wed Jun 06, 2007 1:30 am
by bdlang
Yes, as long as the MySQL server allows connections from either all hosts or the specific host PHP is on, and the MySQL user you connect with is able to connect from the same host.
Do you have administrator privileges on the MySQL server?
Posted: Wed Jun 06, 2007 2:38 am
by jlising
Thanks for the reply.
Yes i have an administrator account.
Posted: Wed Jun 06, 2007 7:44 am
by bdlang
Alright, then it should be easy enough to give the user the permissions they need to access the database(s) from that address. Don't forget to make sure your MySQL server's port 3306 is not blocked, and make sure that it uses TCP to listen on 3306 (take a look at the skip-networking config option, make sure it's commented out in either the server startup or the my.cnf).
Posted: Wed Jun 06, 2007 7:56 am
by feyd
Also, make sure the MySQL user is given just enough permissions to do what it needs, nothing more. That probably means restricted to a few tables, and ability to select, insert, possibly update, but nothing else.
Posted: Wed Jun 06, 2007 8:11 am
by bdlang
I agree. This is also why I don't recommend using the '%' wildcard to allow all hosts to connect.
Posted: Thu Jun 07, 2007 7:09 pm
by jlising
Thanks a lot guys! This is very informative.