Connect to database of an alternative server

The common question:
Is it possible to connect to the database of an alternative server?


More info:

I have a server in a country that my data is in it but the visits of
my site is from another country (e.g my server is in Germany And my
site users are in USA) so the ping is low for my users and I’m gonna
buy a server in my users country.But I’m not gonna move the data from my previous server to the new one for some reasons and otherwise my site has to connect to the DB to load the content so I was in a doubt that is this possible to make a connection from my site in new server to that previous server? I asked it cause I haven’t tried it ever.

Some thing like this (is this correct?):

$dbhost = "I think I should write the ip of the alternative server here";
$dbuser = ....;
$dbpass = ....;
$dbname = ....;
$dbconnection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);

Related:


Leave a Reply