Home > Bash, Linux, Programmering > Backup a MySQL database

Backup a MySQL database

– if you have root access you can do mysql dump.

– if you have filesystem access you may stop mysql / flush tables with read lock and then copy data files.

– dump each of the db one by one!! may be a shellscript will do the job! You may directly redirect it to target db if it’s accesible:

mysqldump -uUSER -pPASS –databases DB1 | mysql -uUSER -pPASS -hREMOTEHOST/IP

To dump all the databases you issue:

mysqldump -uUSER -pPASS –all-databases > dumpfile.sql

and then issue:

mysql -uUSER -pPASS < dumpfile.sql

Categories: Bash, Linux, Programmering Tags:
  1. No comments yet.
  1. No trackbacks yet.