Skip to content

Instantly share code, notes, and snippets.

@fracasula
Last active August 24, 2016 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fracasula/9409931 to your computer and use it in GitHub Desktop.
Save fracasula/9409931 to your computer and use it in GitHub Desktop.
MySQL dump cli command (mysqldump)
# Example 1
mysqldump --databases dbname -u root -p > dbname.sql
# Example 2
mysqldump --databases dbname -u root -pPASSWORD | gzip -c > dbname.sql.gz
# Example 3 (just the schema with no data and disabling foreign keys)
mysqldump -u root -pPASSWORD --no-data --single-transaction --quick --lock-tables=false -y --disable-keys dbname | gzip -c > dbname_schema.sql.gz
# Example 4 (loading the DB back into MySQL)
zcat dbname.sql.gz | mysql -u username -p -h localhost dbname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment