Nasser Heidari

2008-06-09

Mysql Database Backup and Restore

Filed under: Linux — Nasser Heidari @ 11:00

Backup

mysqldump –add-drop-table –default-character-set=utf8 -r <output-file> -u <username> -p<password> <database>

example :

mysqldump –add-drop-table -r backup20060609.sql -u root -p123 mydatabase

mysqldump –add-drop-table –default-character-set=utf8 -u root -p123 mydatabase | gzip > backup20060609.sql.gz

Restore

mysql –default-character-set=utf8 -p<password> -u <username> -D <database> < <input-file>

example:

mysql -p123 -u root -D mydatabase < backup20060609.sql