Reputation: 2535
I currently have a MySQL dump of about 2GBs in size that consists of 10 databases. I need to skip few databases when I restore this dump. I couldn't find a solution on the internet or in Stackoverflow to ignore specific databases upon restoring a dump.
The command I use to restore on Ubuntu is:
$ mysql -u root -p < dump.sql
This command works fine but it restores all DBs. Is there a way to ignore one or many databases using an option like "--ignore-database" while doing this? Ex: DB to ignore "abc_db".
Upvotes: 1
Views: 1549
Reputation: 4040
Ignore statements except those that occur while the default database is the one named on the command line. This option is rudimentary and should be used with care. Statement filtering is based only on USE statements.
mysql -u someone -p somedatabase < all.sql
What you want to do is feed your sql dump directly to the mysql client with a command like this one:
bash > mysql -D your_database < your_sql_dump.sql
If you have access to the server where the dump comes from, then you could create a new dump with mysqldump --ignore-table=database.table_you_dont_want1 --ignore-table=database.table_you_dont_want2 ....
where somedatabase is the name of the database you want to extract and someone is mysql user .
Upvotes: 1