l2t

How to export/dump mysql database?

Asked: 4 days ago

If you want to take mysql database backup or snapshot using Linux/Mac O/S follow commands below:

Exporting sql.gz file using Linux/Ubuntu or Mac O/S

# syntax using mysqldump/gzip
mysqldump -u <mysql-user> -p<mysql-password> <mysql-database> | gzip > /tmp/backup.gz

Export database and upload to s3 bucket

# you need to have aws cli tool installed and configured for following command to work
mysqldump -u <mysql-user> -p<mysql-password> --compress --add-drop-table --quick --skip-lock-tables --single-transaction <mysql-database> | gzip | \
    /usr/local/bin/aws s3 cp - s3://<bucket-name>/backup.sql.gz --region=us-west-1 --expected-size=107374182400
Viewed: 14 times
Liked: 1 times