简体   繁体   中英

Restore a single table from a mysqldump database backup to a different table in the same database?

I've got a 3.5gb database dump. Is there a way to restore just a single table from that file to a differently named table in the same database without editing the file, using mysqladmin, or some other commonly available command line application that runs on FreeBSD 6?

You would need to create the table in restore-db and run something like:

grep "^INSERT INTO table" dump-file | mysql -u user -p restore-db

First make sure that your pattern matches correctly.

cat THE_DUMP_FILE.SQL | sed -n "/^-- Table structure for table \`THE_TABLE_NAME\`/,/^-- Table structure for table/p" > THE_OUTPUT_SQL_FILE_NAME

我在这上面搜索了一段时间,这个解决方案对我来说非常有效,而且似乎是大型转储文件的最快解决方案之一,我的想法来自: http : //code.openark.org/blog/mysql /上复原-A-单表从- mysqldump的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM