Restore a single table from a full mysqldump file
Note: This article assumes that you have installed and configured MySQL® on your server.
Prerequisites
- A MySQL® server
- Access to a MySQL® privileged user such as root.
- A MySQL® dump file of the database that includes the table that you want to import.
Procedure
-
Login into your MySQL® server.
Note: This step can change depending on your OS and user type.mysql -u root -p -
Create a temporary database.
CREATE DATABASE tempdatabase; -
Exit the MySQL® server.
exit; -
Go to the MySQL® dump file directory and execute the following command:
mysql -u root -p tempdatabase < mysqldump.sql -
Login into your MySQL® server to ensure that your database was imported properly and the table exists. (Optional)
Login into your MySQL® server.mysql -u root -pSwitch to the temporary database and show the tables:
USE tempdatabase; SHOW TABLES; exit; -
Export the desire table to a MySQL® dump.
mysqldump -u root -p tempdatabase mytable > mytabledump.sql -
Import the table to the database.
mysql -u root -p mydatabase < mytabledump.sql -
Delete the temporary database.
Login into your MySQL® server.mysql -u root -pDelete the database:
DROP DATABASE tempdatabase; exit;
Updated about 1 year ago
Did this page help you?
