Debian Tutorials Copy/Paste tutorials for Debian based Linux distros

14Sep/091

Moving databases from one MySql server to another

1. On the source database server run the following command to export all databases:

mysqldump -h localhost -u {username} -p --all-databases > database_dump.sql

Replace {username} with your MySql username.

You can also export a single database using this command:

mysqldump -h localhost -u {username} -p {database} > database_dump.sql

Replace {username} with your MySql username and {database} with the database you are going to export.

2. Move the database_dump.sql file to your destination server. You could grab it from FTP server or put it on a public web location and use wget on the destination server to receive the file. This process it outside the scope of this tutorial.

3. Import the dump to the destination MySql server by running the following command:

mysql -h localhost -u {username} -p < database_dump.sql

Replace {username} with your MySql username.

If you are only exporting a single database, use this command instead:

mysql -h localhost -u {username} -p {database} < database_dump.sql

Replace {username} with your MySql username and {database} with the database you are going to export.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Live
  • Slashdot
  • LinkedIn
  • Print
  • Tumblr
  • Twitter
  • Netvibes
  • Netvouz
  • PDF
  • Yahoo! Bookmarks
Comments (1) Trackbacks (0)
  1. You should add –hex-blob to mysqldump export to prevent problem with blob content.


Leave a comment


No trackbacks yet.