【鼠】庚子年癸未月乙卯日 / 五月廿二日
Saturday July 11, 2020

MySQL

MySQL is a relational database management system available under GNU GPL and is currently owned by Oracle.

Standard configuration

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, gb2312 or gbk for native Chinese, or use utf8 for unicode.

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

The MySQL result are ??? instead of Chinese characters

Follow the following steps to determine where the problem is:
Official page : MySQL
MySQL : CJK FAQ
Web front-ends : phpMyAdmin

[ < back ] - [ home ]