Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect to database on another server

Could I have my php scripts on server A and connect to the MySQL database on server B?

If yes, how it would be done? Thanks in advance

like image 749
Ankit Sachan Avatar asked Nov 19 '09 14:11

Ankit Sachan


2 Answers

its simple all thise above techniques are quite complicated

suppose you have database on server B and website on server A(say it has IP 192.234.12.1)

on cpanel whitelist the IP of server B

and create a new user having sufficient privileges in database (say this user is test)

then create this user as [email protected]

like image 89
Ankit Sachan Avatar answered Oct 19 '22 06:10

Ankit Sachan


Yes.

The same way you access the localhost on the same server, you change the database host to the external one. This is more a configuration issue, you need to grant your database user remote access to your MySQL, you also need to make sure your firewall allows connections on the MySQL port.

Example on Debian: http://www.debianhelp.co.uk/remotemysql.htm

like image 38
Francisco Aquino Avatar answered Oct 19 '22 05:10

Francisco Aquino