MySQL BACKUP

single database, create the dump and send the output into a file

mysqldump database_name > database_name.sql

mysqldump -h localhost -u <user_name> -d <database_name> -p > <file.sql>

Multiple databases

mysqldump --databases db_a db_b > two_databases.sql

In the code above, db_a is the name of the first database to be backed up, and db_b is the name of the second.

SYNTAX

mysqldump --all-databases > all_databases.sql

mysqldump -u root -p --all-databases > /database/all_database.sql

WINDOWS

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqldump.exe -u root -p --all-databases > F:\test.sql

RESTORE BACKUP

If backup was taken by using –all-database then no need to create the database or use command directly pass dump to sql.

mysql < all_database.sql

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *