Last active
August 24, 2016 13:49
-
-
Save fracasula/9409931 to your computer and use it in GitHub Desktop.
MySQL dump cli command (mysqldump)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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