How to backup and restore MySQL database?
You can backup your database automatically using this script
Here are the commands to manually do it via shell, given you have root privilege:
Related Posts:To dump the database onto a text file:
mysqldump database_name > database_name.sqlTo import the data into a database:
mysql database_name < database_name.sqlReplace database_name with the name of your database.
linux tips
Use the –opt switch to dumpo with all the options. Below is an example how to dump a database from a script and then packing it in bzip2. Especially usefull if your databses get bigger
.
/usr/bin/mysqldump –user root –password=”password” -opt $db | bzip2 -c > ../dump/db.sql.bz2