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:-
Posted at October 5th, 2006 by chua$ gunzip backup_db.sql.gz
If you think this article helps you to solve your problem and clear your headache, feel free to buy me a drink :)









June 12th, 2007 at 11:49 am
not helpful at all!
January 9th, 2008 at 12:43 am
was helpful
July 2nd, 2008 at 9:21 am
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
August 12th, 2008 at 7:08 pm
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