MySQLMySQL is a relational database management system available under GNU GPL and is currently owned by Oracle.
Standard configurationAll standard MySQL binaries are compiled with
--with-extra-charsets=complex. This will add code to all standard programs to be able to handle latin1 and all multi-byte character sets within the binary. Other character sets will be loaded from a character-set definition file when needed.
Set the default character setBy default MySQL uses the ISO-8859-1 (Latin1) character set. To change the default set, use the following commando:
CHARSET may be one of big5, gb2312 or gbk for native Chinese, or use utf8 for unicode.
Convert charactrs between server and clientUse the SET CHARACTER SET command.
CHARACTER SET character_set_name | DEFAULT
This maps all strings from and to the client with the given mapping. Currently the only option for character_set_name is cp1251_koi8, but you can easily add new mappings by editing the 'sql/convert.cc' file in the MySQL source distribution. The default mapping can be restored by using a character_set_name value of DEFAULT. Note that the syntax for setting the CHARACTER SET option differs from the syntax for setting the other options.
Change character sets of created tablesIf you change character sets after having created any tables, you will have to run
myisamchk -r -q --set-character-set=charseton every table. Your indexes may be sorted incorrectly otherwise. (This can happen if you install MySQL, create some tables, then reconfigure MySQL to use a different character set and reinstall it.) With the option
--with-extra-charsets=LISTyou can define which additional character sets should be compiled into the server. Here LIST is either a list of character sets separated with spaces, complex to include all characters that can't be dynamically loaded, or all to include all character sets into the binaries.
Sorting and SearchingIf you are using Chinese data in big5 encoding, you want to make all character columns BINARY. This works because the sorting order of big5 encoding characters is based on the order of ASCII codes.
- A more simple way is to store all your chinese characters in unicode hexadecimal format. when you do a query from a website, just make sure that the page is set to utf-8.
- Since MySQL 5.1 databases & tables with Chinese characters are supported
The MySQL result are ??? instead of Chinese charactersFollow the following steps to determine where the problem is:
- Is your DB configured to handle Chinese characters ?
- Is your table character set Chinese capable ?
- Check the MySQL variables mysql > SHOW VARIABLES LIKE 'char%';to set all to the same character set usemysql > SET NAMES 'utf8';(change utf8 to your preferred character set).
- Is the targeted display character set the same as your MySQL table ?
i.e MySQL in utf8 while your php page in big5 encoding. To determine if the problem is with your database you can run the command directly in the mysql client.
Official page : MySQL
MySQL : CJK FAQ
Web front-ends : phpMyAdmin
[ < back ] - [ home ]