I have a mysqldump backup of my mysql database consisting of all of our tables which is about 440 megs. I want to restore the contents of just one of the tables form the mysqldump. Is this possible? Theoretically, I could just cut out the section that rebuilds the table I want but I don't even know how to effectively edit a text document that size.
相关问题
- php PDO::FETCH_ASSOC doesnt detect select after ba
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
Table should present with same structure in both dump and database.
or
One way or another, any process doing that will have to go through the entire text of the dump and parse it in some way. I'd just grep for
and pipe the output into mysql. Take a look at the first table in the dump before, to make sure you're getting the INSERT's the right way.
Edit: OK, got the formatting right this time.
This can be done more easily? This is how I did it:
Create a temporary database (e.g. restore):
Restore the full dump in the temp database:
Dump the table you want to recover:
Import the table in another database:
I tried a few options, which were incredibly slow. This split a 360GB dump into its tables in a few minutes:
How do I split the output from mysqldump into smaller files?
A simple solution would be to simply create a dump of just the table you wish to restore separately. You can use the mysqldump command to do so with the following syntax:
Then import it as normal, and it will only import the dumped table.
This is a better solution than some of the others above because not all SQL dumps contain a
DROP TABLE
statement. This one will work will all kinds of dumps.