Wednesday 28 May 2014

HOWTO: backup a mysql db on the command line


To backup a single mysql database, use the following command:

:~$ mysqldump -u my_user_name -p db_name > backup_of_my_db.sql

If compression is needed, the command changes like this:

:~$ mysqldump -u my_user_name -p db_name  | gzip -9 > backup_of_my_db.sql.gz

To extract the compressed .gz file, use the following gunzip command:

:~$ gunzip backup_of_my_db.sql.gz

No comments:

Post a Comment