How do I export/Import Database via Command line

Export  Mysql Database:-

To export your MySQL database using mysqldump. Here’s an example -

1
mysqldump -uUSERNAME -pPASSWORD DATABASENAME > db-backup.sql

Please replace USERNAME, PASSWORD, and databasename with your MySQL database details. Also, the filename database-backup.sql can be changed to anything you like.

Press the Enter key to run the command.

Import Mysql Database:-

To import a MySQL database we’ll use the mysql command. Here’s an example of the full command to import your database:

1
mysql -uUSERNAME -pPASSWORD DATABASENAME < db-backup.sql

Please replace USERNAME, PASSWORD, and DATABASENAME with your MySQL database details. The database has to exist for the import to run.


That's All!


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 8436