access mysql db through different server

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

access mysql db through different server

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] )
string server being your servers IP.
jayloo
Forum Newbie
Posts: 11
Joined: Tue Jun 14, 2005 1:28 pm

Post 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);
User avatar
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 -$
jayloo
Forum Newbie
Posts: 11
Joined: Tue Jun 14, 2005 1:28 pm

Post by jayloo »

Does your user have permission to connect to that host from the other host? What is the error message?
Post Reply