Kamran Akhter
Kamran Akhter

Reputation: 513

which is the best way to share data between two servers

Hi i have mysql databases on two different servers/machines
I need to pull data from server1 and dump in temp table in server 2 on daily basis

Actually the requirement is that when articles on server 1 are ready to be published on store/server2, i want to populate server2/store with that data

Server1 is on lynix and server 2 is on windows dedicated server

So i need to ask which is the best way of accomplish this PHP page with button, web services, windows service windows scheduled task or any thing else
please advise
Thanks

Upvotes: 0

Views: 847

Answers (2)

user1028321
user1028321

Reputation: 11

How about this? I'm aware I'm missing some things, I'm just trying to be brief.

$s1 = mysql_connect("server1");
$s2 = mysql_connect("server2");

$r = mysql_query("select data from table_name where whatever", $s1);

while($row = mysql_fetch_row($r))
{
    mysql_query("insert into table_name ('$row[0]')", $s2);
}

Upvotes: 1

Marko
Marko

Reputation: 522

You could use a cron job triggered commandline script on the linux server. Which does something like:

mysqldump .... server1 | mysql -h server2 -uuser -ppassword db_name

Means dumping the table to stdout and directly piping the dump to server2. The exact syntax you can find in man pages of mysqldump.

Upvotes: 0

Related Questions