Introduction
There are times when you need to extract and restore a specific table from a full backup dump. This can be accomplished by using the sed
command to table to its one .sql file, and then importing the table from that .sql file.
Procedure
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Run the following command to create a new dump file containing only the desired table.
sed -n -e '/DROP TABLE.*`$mytable`/,/UNLOCK TABLES/p' $dump.sql > $mytable.sql
Please note that "$mytable" and "$dump.sql" must be replaced with the table name you want to extract and the original MySQL dump filename, respectively. - Run the following command to import the extracted table.
mysql mydatabase < $mytable.sql
Please note that "$password" and "$mytable.sql" must be replaced with the root MySQL password and the dump file created with the previous command, respectively.
Comments
0 comments
Article is closed for comments.