Export database

$> mysqldump -u DB_USER --password=DB_PASSWORD -h DB_HOST DB_NAME > FILENAME.sql

To compromise (gzip) the output:

$> mysqldump -u DB_USER --password=DB_PASSWORD -h DB_HOST DB_NAME | gzip -9 > FILENAME.sql.gz;

Usefull Params

  • –single-transaction
  • –quick
  • –opt

Export al​l Databases

$> mysqldump -uroot -p -quick --all-databases --skip-lock-tables | gzip -9 > all_dbs.sql.gz;

Through an ssh tunnel

$> ssh user@host "mysqldump -u DBUSER -pPASSWORD db | gzip -9 -c" > ~/PATH/TO/dump.sql.gz

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.