Thursday, April 11, 2019

MySQL: dump table to a file and make a copy in a new database


1. Dump the table MyTable1 in database MyDatabase1 into a file:

$ mysqldump -u mydbusername -p MyDatabase1 MyTable1 > MyTable1.dump

Enter the DB password. The data of the table is saved into MyTable1.dump.

2. Run the mysql client:

$ mysql -u mydbusername -p

3. Create a new database:

MYSQL> create database MyDatabase2

4. Clone the table:

MYSQL> source /path/to/MyTable1.dump





No comments:

 
Get This <