Home >Database >Mysql Tutorial >How to Export and Import MySQL Databases via the Command Line with Options?
How to Export and Import a .SQL File from the Command Line with Options
Not a duplicate! This question seeks features similar to phpMyAdmin's export functionality for the command line.
Exporting a Database
To export a MySQL database to a .sql file, use the mysqldump command along with the following options:
Example:
mysqldump -u username -p databasename > database-backup.sql
Importing a Database
To import a .sql file into a MySQL database, use the mysql command:
Example:
mysql -u username -p DATA-BASE-NAME < data.sql
Options for Exporting and Importing
The following options can be used to customize the export/import process:
Example (disable foreign key checks during export):
mysqldump -u username -p --disable-foreign-key-checks databasename > database-backup.sqlThe above is the detailed content of How to Export and Import MySQL Databases via the Command Line with Options?. For more information, please follow other related articles on the PHP Chinese website!