Heath SchweitzerHeath Schweitzer
← 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:

  1. 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
  2. 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.

Bitcoin tip QR code
⚡ Open in Wallet