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