← All posts

How to backup a MySQL database from the command line
November 1, 2016|Heath Schweitzer|1 min read|28 views|Last Updated June 16, 2026
LinuxTechnology
Simple command line options to backup a MySQL database:
- backup a database locally using mysqldump, date and time in the filename, and compression
mysqldump -uUSERNAME -pPASSWORD DATABASE | gzip -9 > ~/$(date +%Y-%m-%d-%H%M)_intiotpa_stage.sql - import compressed file back into database
gunzip < ~/backups/FILENAME.sql.gz | mysql -uUSERNAME -pPASSWORD DATABASE
If this post was useful, consider buying me a coffee ☕ with ₿itcoin — no account needed, any amount welcome.