If you, like me, happen to end up with a mysqldump –all-databases dump file and need to restore a single database, here’s how (replace Target with your database name):
|
1 |
$ sed -n '/^-- Current Database: `Target`/,/^-- Current Database: `/p' -o Target.sql dump.sql |
Note the use of -o instead of output redirection (>), since it’s locale independent.
If you have seem to have a charset mismatch, say UTF-8 – ISO-8859-1 issues, convert the dump using iconv.
|
1 |
$ iconv -f UTF-8 -t ISO-8859-1 -c -o Target.iso.sql Target.sql |