I've got a sql file produced by "mysqldump --all-databases" . You will find many databases inside it. What I wish to do would be to update my local database only a particular one, not every. I attempted to make use of "mysql -database=db_title < file.sql" however it up-to-date all databases. It is possible to method to skip all databases except the one which I would like.
You can test doing:
mysql -D example_database -o < dump.sql
This can only execute the
SQL instructions for that specified database and can skip the instructions for those other databases. The [cde] ("one database") option is critical for this being employed as expected (it informs
-o to disregard claims associated with other databases).
mysql is caused by performing
it's getting dirty, stop reading through if or perhaps be cautioned )
It isn't pretty and perhaps there's a much better (correct) method to achive this. But presuming the dumps you're dealing with aren't to large, you may be faster by posting the entire dump into temporary DBs and developing a fresh dump from the database you want to import. (When I stated, not pretty)
Furthermore, you need to really make certain that you are in a position to restore backup copies you are making (in almost any imaginable way). This might get really embarrassing your day you'll need them urgently.
A few ideas:
You are able to edit the dump file (it is simply a text file, in the end), removing just the products associated with the database you need to restore. I believe each database is written towards the file individually, making this dependent on determining the main one large block associated with the main one you would like and removing the bits pre and post it -- e.g., much less stressful because it sounds. Search for the
create databaseclaims (additionally, there are -- a minimum of during my version, with my options) a banner comment "Current Database:
use" towards the top of each section). This is pretty easy related to
fooor other things that allows you need to do large procedures easily. After that you can sort through the end result making certain that you will find no mix-references towards the DBs you wouldn't want up-to-date.
You are able to support the databases you wouldn't want up-to-date, perform the update, then restore them. I am talking about, before you decide to do that kind of factor, you've got a backup anyway, right? -)
You are able to restore to some blank MySQL instance, grab the backup from the one you would like. Blech.
(Variation on #3) You are able to perform a relabel on all your current databases, import the file, then drop those you wouldn't want and relabel the originals back. Also blech.
I'd most likely opt for #1 (following a full backup). Have fun with it.
Edit No, I'd opt for codaddict's [cde] solution (following a full backup). Nice one