0

I have multiple Wordpress databases stored on a VPS. I am using the following command to back them up:

# mysqldump -u root -p password --all-databases > /tmp/all-database.sql

This creates a single file. Is there anyway to restore specific databases from this dump?

user970638
  • 273
  • 1
  • 2
  • 10

1 Answers1

0

You can use the --one-database option

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.

so

mysql -u someone -p somedatabase <all.sql 

Should work as you want and be reasonably safe for but note the emphasis above and read the notes in the documentation

It would probably be safer though to extract the database you want rm the dump. Something like

sed -n '/^-- Current Database: somedatabase/,/^-- Current Database: `/p' all.sql > somedatabase.sql

where somedatabase is the name of the database you want to extract.

user9517
  • 114,104
  • 20
  • 206
  • 289