Follow us on Twitter!
Subscribe to AppGini tips and tutorials using your favorite RSS news reader by clicking the link to the right.
Read more AppGini tips and tutorials
Quickly backup and restore your MySQL database
It's very important that you have a backup plan of your MySQL database. Loosing even a single day's worth of data can be frustrating and critical to your business. If you have shell (command-line) access to your database server, here is a very easy and quick backup method: Use mysqldump.
Creating the backup
To create the dump, use this command from your shell/command-line:mysqldump -uusername -ppassword –default-character-set=utf8 -N database > backup.sql
Where:
- username is your MySQL username.
- password is your MySQL password.
- database is the name of the database you want to backup.
- backup.sql is the full path to the mysql dump file that will contain the backup.
Restoring the database from your backup
Restoring a database from a backup file is pretty easy. First, empty the database to avoid error messages, then run this command:mysql -u username -p password –default-character-set=utf8 database < backup.sql
Where:
- username is your MySQL username.
- password is your MySQL password.
- database is the name of the database you want to restore.
- backup.sql is the full path to the mysql dump file that you want to restore from.
That's it! Now you have no excuses! Start making a regular backup of your database from today.
