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
access mysql db through different server
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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);- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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...
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 -$