How to Back Up and Restore a MySQL Database
If you’re storing anything in MySQL databases that you do not want to lose, it is very important to make regular backups of your data to protect it from loss.
Backup
1. Open a Command Line or Shell
2. Use the following command to backup the database with the name test.
1 |
mysqldump --opt -u username -p test > test.sql |
Restore
First create a database and log into the mysql shell as a privileged user:
1. login mysql: mysql -u root -p
2. CREATE DATABASE test;
3. Restore the test database
1 |
mysql -u username -p test < test.sql |
Leave a Reply