Can a Single Table Be Restored from a Full MySQL mysqldump File?
Restoring a particular table from a comprehensive MySQL mysqldump backup containing all tables is feasible.
Solution:
Utilize the "sed" command to extract only the desired table. For instance, given a mysqldump file named "mysql.dump" and a table named "mytable":
$ sed -n -e '/CREATE TABLE.*`mytable`/,/Table structure for table/p' mysql.dump > mytable.dump
This command will create a new file, "mytable.dump," containing everything between CREATE TABLE mytable and the next CREATE TABLE for another table.
Modify "mytable.dump" to include the table structure and data inserts. Subsequently, you can import the restored table using a database tool.
The above is the detailed content of Can I Restore a Single MySQL Table from a Full mysqldump?. For more information, please follow other related articles on the PHP Chinese website!