Skip to content
Advertisement

Is there a way to import all databases into one database with Mysqldump?

I want to gather automatically all my databases into one with Mysqldump, is there a way to do it ?

For example what I want is to move all the tables from DB1, DB2 and DB3 into DB4 (DB4 can already contain some tables or can be created during the import, it doesn’t matter to me).

I tried mysqldump -uroot -p –all-databases > dump.sql

Then import it with mysql -uroot -p allInOne < dump.sql

But the resulting database is only filled with it’s own data.

Advertisement

Answer

I think you will have to do the databases individually but with:

mysqldump -uroot -p DB1 > dump.sql

This will not include the Database name and Use in the dump so you can re-import into the new database.

If you really have a lot of databases then not sure if any of the other options will help :https://dev.mysql.com/doc/refman/5.5/en/mysqldump.html

Might be worth exploring:

mysqldump -uroot -p --all-databases --tables > dump.sql
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement