How to import UTF-8 encoded files into MySQL without outputting garbage

A recent Drupal localization project proved relatively painless until we moved the data from a local machine to a staging server. Importing thousands of lines of Bulgarian into a MySQL database went smoothly BUT when Drupal pulled the data it looked like gibberish.

The database’s collation was properly set to UTF-8 but it refused to output Cyrillic instead of garbage. The solution? Edit your MySQL options file to change the server’s character set to UTF-8. Adding character-set-server = utf8 to my.cnf should do the trick.

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="" highlight="">