
Use mysqldump to export a whole database, a single table, or just the structure, then import with the source command — a quick reference for MySQL backup and restore.
1. Export the whole database
mysqldump -u USER -p DBNAME > OUTPUT.sql
e.g. mysqldump -u root -p dbname > dbnamebak.sql2. Export a single table
mysqldump -u USER -p DBNAME TABLE > OUTPUT.sql
e.g. mysqldump -u root -p dbname member > dbname_member.sql3. Export structure only
mysqldump -u root -p -d --add-drop-table dbname > d:/dbname_db.sqlNote: -d exports no data; --add-drop-table adds a DROP TABLE before each CREATE.
4. Import (commonly via source)
Enter the MySQL console:
mysql -u root -p
mysql> use DBNAME
mysql> source d:/dbnamebak.sqlThe argument after source is the script file (here a .sql file).
