How to restore single table my MySQL database backup

1158120 pts.
Tags:
Backup
Database
MySQL
We currently have a mysqldump that backups our MySQL database (which has a bunch of tables with roughly 440 MBs). We've been trying to restore one of the tables from the mysqldump. Would that be possible? Thanks so much!
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Yes, it is possible.

The dump is actually a text file with all the commands needed to recreate your objects and insert the appropriate data.  You can open the dump file and look for the name of your table. It usually starts with a comment, then you have a DROP TABLE, a CREATE TABLE, and some INSERTs.  Just copy all the related lines of text to a new file and execute it on the desired database to restore the table.

With huge files it can be necessary to do this from the terminal with some shell commands (sed or awk for example) to avoid having to open the file with a text editor, but in this case it should be easy to do it manually.

Another possibility could be to restore the whole backup on another server and then dump only the desired table, so you can use that new dump to restore only that table in your production server.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: