MySQL不支援GBK編碼的解決方案

來源:互聯網
上載者:User

Linux下用packages安裝的MySQL5.1,不支援GBK編碼,只支援UTF8編碼。具體表現:

在開啟一個用GBK編碼的資料庫時,提示

ERROR 1273 (HY000): Unknown collation 'gbk_chinese_ci' in table 'data_plus' definition

set names gbk; 和 SET character_set_client = gbk;提示:

ERROR 1115 (42000): Unknown character set: 'gbk'

最後沒辦法,只好用ports重新編譯。

cd /usr/ports/databases/mysql51-server

make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_COLLATION=gbk_chinese_ci BUILD_STATIC=yes install clean

(其實,在make install clean 時,就有個參數提示,把前三個設定好就可以了。)

查看支援的編碼:

SHOW VARIABLES LIKE 'character_set_%';

SHOW VARIABLES LIKE 'collation_%';

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.