Restoring MULTIPLE MySQL databases from one file at the command line?

I have exported all my databases to a file using phpMyAdmin.

Unfortunately I don't have a working phpMyAdmin in my destination system.

How should I restore all of them at once using one line command?


Why don't you concat all the files into one single file and import/restore using

mysql -u username -p < dump.sql

Create one file using

mysqldump -u username -p --all-databases > dump.sql

If you backed up many database to 1 file, I suppose you backed up the create database statements in the same file. If not you only need to add the create database and use database statements to your file at the proper places.

After that, the command to load the file to mysql is:

mysql -p < sqlfile.sql

-p is to ask for your password.

You can use -u username if you need to use another user.


mysql command to restore sql file is :

mysql DATABASE_NAME < SQL_FILENAME.sql

first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :

gunzip SQL_FILE.sql.gz