Skip to main content

Dump / Export / Import - MySQL

Export / Dump

caution

PowerShell output redirect ( mysqldump > file.sql ) will use UTF-16, MySQL cannot import UTF-16

CLI
mysqldump [-u <user>] [-p]
{ --all-databases | <database> [<table> [...]] }
[ --where="<where clause>" ]
[ --events | --skip-events ]
[ --routines | --skip-routines ]
[ --triggers | --skip-triggers ]
--result-file=<file.sql>

Export with gzip

mysqldump <database> | gzip [-9] > <file.sql.gz>

Ref: mysqldump

Ref: Dumping Stored Programs

Import

mysql [-u <user>] [-p] <database> < <file.sql>

or

use <database>;
source <file>;