MySQL Snippets

Take a backup

# entire database
mysqldump -p -u username db_name > db_name.sql

# just schema
mysqldump -p -u username --no-data db_name > schema.sql

# just data
mysqldump -p -u username --no-create-info db_name > data.sql

# just one table
mysqldump -p -u username db_name table_name > db_name.tabel_name.sql

# Other useful switches
--host localhost
--ignore-table=db_name.table_name

Load from backup

mysql -p -u username db_name < db_name.sql