Backup Mysql In Command Line With Compression

Discussion in 'MySQL' started by 123addme, Jan 26, 2013.

  1. #1
    For those who looking for way to backup mysql database,
    you can use mysqldump to backup mysql database.
    Below is the script example to backup mysql database in command line:-

    $ mysqldump -h localhost -u username -p password database_name > backup_db.sql
    Code (markup):
    If your mysql database is very big, you might want to compress your sql file.
    Just use the mysql backup command below and pipe the output to gzip,
    then you will get the output as gzip file.

    $ mysqldump -u username -h localhost -p password database_name | gzip -9 > backup_db.sql.gz
    Code (markup):
    If you want to extract the .gz file, use the command below:

    $ gunzip backup_db.sql.gz
    Code (markup):

     
    123addme, Jan 26, 2013 IP