mysqldump -u root -p mydb > mydb.sql

Category: Databases & SQL

mysqldump -u root -p mydb > mydb.sql

Back up a database to a SQL file

Writes CREATE TABLE and INSERT statements to stdout; redirect into mydb.sql. Restore with mysql mydb < mydb.sql. Add --routines --triggers to include stored programs and triggers. Related: mysqldump --all-databases.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.