03 Apr 2018

How to export / import database in linux via cmdline

Export full database

For export database , following command is to be used (where username is database user)
Enter the password when prompted

mysqldump -uUSERNAME -p USER_DATABASE > FILENAME.sql

Then import using:

mysql -uUSERNAME -p USER_DATABASE < FILENAME.sql

 

Export /dump particular table from a database :

For exporting particular tables from a database, following command is used :

mysqldump -uUSERNAME -p USER_DATABASE table1 table2 ... tabllenĀ > FILENAME.sql