How To: Back Up MySQL Databases From The Command Line

To back up a single database

mysqldump database_name > database_name.sql

Multiple databases can be backed up at the same time:

mysqldump --databases database_one database_two > two_databases.sql

To back up all of the databases on a server:

mysqldump --all-databases > all_databases.sql

Restoring a Backup

Restore single Database

mysql database_name < database_name.sql

To restore a single database from dump of all the databases

mysql --one-database database_name < all_databases.sql

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s