PDA

View Full Version : connecting from another server possible?


perayo
01-14-2004, 08:24 PM
Is it possible to connect to a database from another server?

I'm using these lines:
mysql_connect ("localhost", "my_user", "my_pass") or die ();
mysql_select_db ("my_db");

All I have to do is change "localhost" right? to...? Kinda lost...
Thanks.

raf
01-15-2004, 12:10 AM
Inside PHP, you indeed only need to change the localhost to the hostname or IP od the server you want to connect to
mysql_connect ("localhost", "my_user", "my_pass") or die ();
mysql_select_db ("my_db");

But your mySQL account should be defined so that you can connect to the server from another one then 'localhost'.
So if you would like to connect to the server from host blabla.com, then your grant-command should have the username in this form
user@blabla.com

For more info on grant:
http://www.mysql.com/doc/en/GRANT.html