Moving a MySQL Database

When moving hosting provider, you may need to move a dataase. Here are the commands I have used on a linux box to shift a MySQL database from one server to another.

To export the database:

mysqldump -h DBSERVER -u DBUSER -p DBNAME > DBNAME.sql

Substituting DBSERVER with the hosts adddress, DBUSER with your MySQL username on the current server and DBNAME with your database name. You will be prompted for your password, after you will have a file in the current working directory called DBNAME.sql containing your entire database.

To import the database:


Again substituting DBSERVER, DBUSER and DBNAME but thistime with your new servers information. You can also change the database name and user at this point, providing the change is reflected in your web apps config.

(Visited 102 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.