Debian Tutorials

Debian Tutorials


Step by step tutorials showing you how to install and configure various applications and services on Debian based Linux distros.

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories


Moving databases from one MySql server to another

Ástþór IPÁstþór IP

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.

Comments 1
  • macsim
    Posted on

    macsim macsim

    Author

    You should add –hex-blob to mysqldump export to prevent problem with blob content.