Skip to main content

Unicode Character Not Displayed Properly with MySQL

I have Chinese/Vietnamese characters, but when I query it into a report, the characters are not displayed properly?

Make sure the default character set and collation in your database is set up to be UTF8. We recommend that you use UTF8 as the default character set and utf8_general_ci for your default collation.

You can change it in your /etc/my.cnf from your db server.

# Change the MySQL database collation to UTF-8
ALTER DATABASE my_database DEFAULT COLLATE utf8_unicode_ci;

# Change the MySQL database character set to UTF-8
ALTER DATABASE my_database DEFAULT CHARACTER SET utf8;

# These settings should be in my.cnf
skip-character-set-client-handshake
collation_server=utf8_unicode_ci
collation_connection=utf8_unicode_ci
collation_database=utf8_unicode_ci
character_set_server=utf8
character_set_database=utf8





Let us know what you think about this document :)