fracasula
3/7/2014 - 11:31 AM

MySQL dump cli command (mysqldump)

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