Being a brave sys-admin I do backup my mysql databases. But, begin to lazy to give each of my databases his own backup-script, I backup all the databases in one dump.
Sofar (triple knock on wood) I had only once to restore a database from that file. I did a couple of greps on the large file to create a file with only the database to restore. But Mike Hillyer has an excellent tip on his blog. I wonder when that option (-one-database) has been introduced, because it’s the first time I’ve heard of that option.
But here is the procedure:
Start my launching mysql client with –one-database
mysql -u root -p –one-database mydatabase
Then use the SOURCE command:
The –one-database option forces the mysql client to ignore statements intended for any database other than the one you specified when you launched the client, allowing you to restore your database without affecting any other databases.