ProblemYou're executing SQL statements or producing query results that don't use the default character set. SolutionUse SET NAMES or an equivalent method to set your connection to the proper character set. DiscussionWhen you send information back and forth between your application and the server, you should tell MySQL what the appropriate character set is. For example, the default character set is latin1, but that may not always be the proper character set to use for connections to the server. If you're working with Greek data, trying to display it using latin1 will result in gibberish on your screen. If you're using Unicode strings in the utf8 character set, latin1 might not be sufficient to represent all the characters that you might need. To deal with this problem, configure your connection with the server to use the appropriate character set. There are various ways to do this:
By the way, you should make sure that the character set used by your display device matches what you're using for MySQL. Otherwise, even with MySQL handling the data properly, it might display as garbage. Suppose that you're using the mysql program in a terminal window and that you configure MySQL to use utf8 and store utf8-encoded Japanese data. If you set your terminal window to use euc-jp encoding, that is also Japanese, but its encoding for Japanese characters is different from utf8, so the data will not display as you expect. NOTE
ucs2 cannot be used as the connection character set. |