MySQL

mysql: backup databases

Backups

all databases

mysqldump -u [user] -p[password] --all-databases > [filename].sql

 

specific databases

mysqldump -u [user] -p[password] [database_name] > [filename].sql

 

restore

mysqldump -u [user] -p[password] [database_name] < [filename].sql

 

backup specific table from a database

mysqldump -u [user] -p[password] [database_name] [table] > [filename].sql

 

backup specific table with a different name (works cool to do migrations of large databases)

mysqldump -u [user] -p[password] [database_name] [table] | sed 's/table/new_table_name/g' > [filename].sql

 

Leave a Reply

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