Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Connecting one MySQL server to another server

Data transfer from one MySQL server to another

7:58 pm on Nov 5, 2011 (gmt 0)

New User

joined:Nov 5, 2011
posts: 1
votes: 0

I am trying to write a query on one MySQL server to access data on another MySQL server. Any idea how to do it?

I tried with a query as below

Select * from hostnameB.DBname.table

Where this query was tried to execute on MySQL server with hostname A and table to access was on hostname B. It didn't work.
Is there any other way to do this?
4:52 pm on Nov 7, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Welcome aboard Dpkb, first you have to allow remote access from the remote server. Generally this is accessed via some control panel (Cpanel, WHM, Plesk), you enter the "allowed remote hosts." You'd turn remote access on and enter site A as (one of, there can be multiple) allowed remote host.

Next is to determine why "it doesn't work." Error trapping is critical for this, a simple PHP example,

$link = mysql_connect(DBHOST,DBUSER,DBPASSWORD,true) or die ("Could not connect to remote server" . mysql_error());

In your case, I'd expect "permission denied for user@localhost" or something similar.