How to backup MySQL Database in command line with compression

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 database_name > backup_db.sql

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 database_name | gzip -9 > backup_db.sql.gz

If you want to extract the .gz file, use the command below:-

$ gunzip backup_db.sql.gz

Technorati Tags: , , , , , , , , , , ,

Share and Enjoy:
  • Reddit
  • BlinkList
  • del.icio.us
  • Digg
  • Fark
  • IndianPad
  • StumbleUpon
  • YahooMyWeb
Posted at October 5th, 2006 by chua

If you think this article helps you to solve your problem and clear your headache, feel free to buy me a drink :)

Related Post

4 Responses to “How to backup MySQL Database in command line with compression”

  1. aa Says:

    not helpful at all!

  2. Matt Says:

    was helpful

  3. rr Says:

    well, im using mysql query browser, and i want to update fields and tables, so.. how can i back up my old field contents?? i dont want to retype them

  4. vinayak Says:

    well, im using mysql query browser, and i want to update fields and tables, so.. how can i back up my old field contents?? i dont want to retype them

Leave a Reply