Importing UTF-8 into MySQL

The MySQL command line tool does not correctly handle UTF-8 encoded source files by default. If you use the ‘source’ command, Japanese turns into garbage. :(

To fix this, use the --default-character-set=utf8 option, e.g.

$ mysql -u username --default-character-set=utf8  -p

This should allow you to use the ‘source’ command to import your foreign language or otherwise special characters into MySQL without trouble.

This entry was posted in SysAdmin and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">