How Can We Help?
< All Topics
Print

How to export/Import Database via Command line

Export  Mysql Database:-

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

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

Please replace USERNAME, PASSWORD, and database names 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:

1mysql -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.

Table of Contents