MySQL backup and restore

MySQL backup and restore

Backing up MySQL


mysqldump is an easy to use tool for creating MySQL backups. This tool will create a text file full of the sql statements needed to create your database as it was at the time of executing mysqldump. Please note that these files can get very big so it’s not recommended to open the backup in a text editor.


You can See everything that mysqldump here

Creating a backup for a single database.

mysqldump -uuser -ppassword database database.sql

Creating a back up for multiple databases.

mysqldump -uuser-ptmppassword --databases database1 database2 database1_database2.sql

Creating a back up of all databases.

mysqldump -uuser --all-databases all_databases.sql

Restoring MySQL.

mysql -uuser -ppassword
create database database1;

mysql> exit

mysql -uuser -ppassword database1 < database1.sql