Ads

Moving a MySQL Database

I have moved hosting provider, and I have had to move the database too. Here are the commands I used to shift the 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:

mysql -h DBSERVER -u DBUSER -p DBNAME < DBNAME.sql

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.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>