Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.