Mysql
將 character_set_client 的值設置為 utf8mb4
我正在嘗試將我的數據庫轉換為
utf8mb4
遵循本指南。我已經設定:[client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] init-connect='SET NAMES utf8mb4' collation_server=utf8mb4_unicode_ci character_set_server=utf8mb4 skip-character-set-client-handshake
但是
character_set_client
and的值character_set_results
仍然不會變成utf8mb4。mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'; +--------------------------+--------------------+ | Variable_name | Value | +--------------------------+--------------------+ | character_set_client | utf8 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | collation_connection | utf8mb4_unicode_ci | | collation_database | utf8mb4_unicode_ci | | collation_server | utf8mb4_unicode_ci | +--------------------------+--------------------+
我究竟做錯了什麼?如何將這些值設置為 utf8mb4?
**披露:**我是How to support full Unicode in MySQL databases的作者,您正在遵循的指南。
- 您將修改後的設置保存在哪裡?檢查
mysqld
從哪裡載入預設選項。通常是/etc/my.cnf
(如指南中所述),但在您的系統上可能會有所不同。執行以下命令找出:$ mysqld --help --verbose 2> /dev/null | grep -A1 'Default options' Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
- 您是否在進行更改後
mysqld
通過執行重新啟動?mysqld restart