Saturday, August 1, 2015

Copy MySQL data from one machine to another

  • Go to the source machine. Dump the database to a file.
      $ mysqldump -u <user-name> -p <database-name> > src-file
  • Login to the destination machine and copy the file over.
      $ scp <remote-location-of-src-file> dest-file
  • (Optional) If we only want to import incremental data, edit the file and remove all the statements of DROP/CREATE TABLE, and change the INSERT statements to INSERT IGNORE.
  • Import the data to the destination database.
      $ mysql -u <user-name> -p <database-name> < dest-file

No comments:

Get This <