MySQL

All 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 set
By default MySQL uses the ISO-8859-1 (Latin1) character set. To change the default set, use the following commando:
./configure --with-charset=CHARSET
CHARSET may be one of big5, cp1251, cp1257, czech, danish, dec8, dos, euc_kr, gb2312, gbk, german1, hebrew, hp8, hungarian, koi8_ru, koi8_ukr, latin1, latin2, sjis, swe7, tis620, ujis, usa7, or win1251ukr.

Convert charactrs between server and client
Use 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 tables
If you change character sets after having created any tables, you will have to run myisamchk -r -q --set-character-set=charset on 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=LIST you 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 Searching
If 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.

Other
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.

Official page : MySQL
Web front-ends : phpMyAdmin

[ < back ] - [ home ]

   
Search >


Local links are in blue, links to other websites are in red, commands are in green.

You need unicode fonts, a 4+ browser and acrobat reader to fully explore and enjoy this webpage. (if necessary you can download asian fontpacks for acrobat reader)

Currently translating my thesis to English : more info

© Seba - contact at seba at ulyssis dot org
users online: 2