Import / Export a mysql database on the command line

To export a mysql database (as a dump) from the command line run:

mysqldump database_name > database_exportname.sql

To import a mysql database dump into a database:

mysql database_name < database_exportname.sql

To export all databases into a dump:

mysqldump --all-databases > all_databases_export.sql

To import one of these mysql databases from the dump into a database:

mysql --one-database database_name < all_databases_export.sql

Leave all Comment