Linking to external database mysql

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
adrian27uk
Forum Newbie
Posts: 2
Joined: Thu Jun 20, 2002 6:18 am

Linking to external database mysql

Post by adrian27uk »

I need to know how I can link to an external database mysql. Php scripts held on one server, and mysql database held on another. I was just interested in finding out if this was at all possible.

Many Thanks
Ade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

mysql_connect:resource mysql_connect ( [string server [, string username [, string password [, bool new_link]]]])
If connections are not blocked between the two servers it works
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

You will need to create a user in mysql which is allowed to connect from a remote location. Lets say your PHP server IP is 192.168.1.1, your database on mysql is called mydb and the user name you want is myuser, from the mysql command line you can type this

mysql> grant all privileges on mydb.* to myuser@192.168.1.1 identified by 'mypassword';
mysql> flush privileges;

This will create a user called myuser with the password mypassword that has rights to connect from 192.168.1.1
Post Reply