Jump to content

mysql sync


chaiwei

Recommended Posts

Hi,

 

I want to have mysql sync between two same application different host using same databases.

So I need to create two connection in php?

Ok , example, server A and server B

 

So if I want to sync FROM  A  to  B 

So I drop all the table in B first,

then create the new table in B

then select * table from server A using php and INSERT INTO server B ?

 

or I create a sql file from server A after that using import into server B is more efficient?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/188990-mysql-sync/
Share on other sites

oops, sorry..

 

I have a live application and database in SERVER A,

then my boss want to use the application even offline (without internet),

So I need to install xampp in his computer,

then I need to create a button that let him press once

and the live database will pump inside the xampp database.

 

Normally I can use phpmyadmin to export into a sql file,

and then use pendrive and copy to my boss pc, and import again.

but he don't want like this, what he want is create a button and once press,

the application will look up the live database, and insert in his own pc database,

so his pc will have the latest updated data.

 

I only can come with the idea is create a script and with two connection,

$conn = mysql_connect('192.168.2.4' , xxx,xxx)
$conn1 = mysql_connect('192.168.2.5', xxx, xxx)

SELECT * FROM -> using $conn
while(xxx xxx){

  INSERT INTO -> using $conn1

}

 

but if the database is large, then the process will take very long time to complete.

 

right?

 

So I wonder whether the above example will slower compare to use phpmyadmin to export and then import again?

 

if that any other ways to complete this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/188990-mysql-sync/#findComment-997854
Share on other sites

I stuck at here. 

 

      $sql = 'SHOW TABLES';
             $result = $remote->query( $sql );
             foreach($result->rows as $value){
                 $sql = 'SELECT * FROM '. $value['Tables_in_commerce'].'<br />';
                 $local->query('Create TABLE '. $value['Tables_in_commerce']);
           

             }

 

Create table xxx xxx

 

How I gonna get the field name, field type, primary key, collaction

and put in the create table syntax?

 

Link to comment
https://forums.phpfreaks.com/topic/188990-mysql-sync/#findComment-997929
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.