Importing a MySQL database dump

All database/MySQL tutorials


If you are moving your database from one server to another (for example to your newly created database on your Gandi server), you can simply perform the following.

This technique is especially useful when the database size is large. For smaller imports, you can also use phpmyadmin if you have installed it on your server.

Export your database

First, export your database from your existing database (the old server).

Transfer the database dump to your Gandi server

Using your preferred method, upload the dump file (ex: mydatabase.sql or mydatabase.dump, etc.) to your new server.

Insert your dump into the new database

Insert the database dump into your new MySQL database by typing the following:

mysql -p -h localhost newdatabase < olddatabase.sql  

where localhost can be replaced with the name of your server's domain name if you have one, where newdatabase is the name of your new database, and where olddatabase.sql is the name of the dump file from your old MySQL database.

In the event that you move your database from an older version to version 5, this will often cause a problem of compatibility with the older php code.

If you get an error message of the type “MySQL returned error “1054: Unknown column (…)”, you will need to check to see if your application that uses the database has an upgrade for version5. (for example: /maintenance/upgrade.php for MediaWiki…).

See also

Last modified: 07/17/2012 at 09:06 by Amy B. (Gandi)