Page 1 of 1
access mysql db through different server
Posted: Sun Jun 12, 2005 1:59 pm
by Bomas
does anybody know how to access a mysql database which is located on a different server?
i can access both servers and, what i want is this:
include a file from the server with the database on my other server and get some information out of it.
i need this cause i want to make a register-check if you have downloaded something from my site
Posted: Sun Jun 12, 2005 2:30 pm
by John Cartwright
resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] )
string server being your servers IP.
Posted: Tue Jun 14, 2005 1:49 pm
by jayloo
or ...
Code: Select all
$host = "192.168.1.100";
$user = "user";
$pass = "pass";
$db = "food";
$table = "places";
mysql_connect ($host,$user,$pass);
mysql_select_db ($db);
Posted: Wed Jun 15, 2005 4:36 am
by Bomas
this i know, but i cant access my database on the other server.
i thought maybe i could access it by including a page on that other server, but i can't get data out of the mysql database
it returns an error
Posted: Wed Jun 15, 2005 7:30 am
by Chris Corbyn
The error being?
By the way... you'll have to give the other server privileges to access the database.
If you're not familiar with the mysql client from the command line CPanel usually offers this too.
But command line wise...
Code: Select all
bash -$ mysql -u username -p
password:
Welcome bla bla bla here....
mysql> GRANT ALL PRIVILEGES ON databasename.* TO 'username'@'other_servers_ip' IDENTIFED BY 'password';
Query OK 0 rows affected
mysql> exit;
Bye
bash -$
Posted: Fri Jun 17, 2005 10:30 am
by jayloo
Does your user have permission to connect to that host from the other host? What is the error message?