mysqldump restore a single table in a backup

Source: Internet
Author: User

Export a single table in a ⒈mysqldump backup
Many times we need to recover a table from the mysqldump backup file, it is often possible to restore the SQL file to a test database, and then use mysqldump to export a table, and then restore to the production environment, so that if the amount of data is not enough this method is feasible, But you still need to have a test machine or temporarily create a library, not very convenient, you can use awk/sed to solve related problems:
① use show tables in the original database;
② using SED or awk to import data into a file (note the sort between tables)
# awk '/^--table structure for table ' stat_map '/,/^--table structure for table ' station '/{print} ' testdb.sql>/usr/yzx _loadtest/recovered_stat_map.sql
Or
#cat Mydumpfile.sql | Sed-n-E '/table structure for table. test1./,/table structure for table. test2./p ' >/tmp/extracted_table.sql
③ recovering from. sql
Mysql-u root-p </tmp/extracted_table.sql

This article is from the "Wind Water" blog, please be sure to keep this source http://linuxybird.blog.51cto.com/5689151/1638069

mysqldump restore a single table in a backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.