MySQL utf8mb4 字元集:支援 emoji Emoji

來源:互聯網
上載者:User

標籤:

我用他的方法解決了問題,親測可用,不要用Navicat for Mysql去查詢編碼,
在伺服器中以root命令進入mysql,用show variables like ‘char%‘;命令查詢的編碼才是最準確的.

㈠ 序言

為了應對無線互連網的機遇和挑戰、避免 emoji Emoji帶來的問題、

涉及無線相關的 MySQL 資料庫建議都提前採用 utf8mb4 字元集

這必須要作為移動互連網行業的一個技術選型的要點

㈡ 限制

需要 >= MySQL 5.5.3版本、從庫也必須是5.5的了、低版本不支援這個字元集、複製報錯

㈢ 簡要步驟

以下是一個未升級到 5.5.3 的配置步驟:

① 備份資料庫

② 升級 MySQL Server 到 v5.5.3+

③ 修改 database、table和column字元集

For each database:ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;# For each table:ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;# For each column:ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)

④ 修改 my.cnf

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘SET NAMES utf8mb4‘

⑤ 重啟 MySQL Server、檢查字元集

mysql> SHOW VARIABLES WHERE Variable_name LIKE ‘character\_set\_%‘ OR Variable_name LIKE ‘collation%‘;
+--------------------------+--------------------+
| Variable_name            | Value              |
+--------------------------+--------------------+
| character_set_client    | utf8mb4            |
| character_set_connection | utf8mb4            |
| character_set_database  | utf8mb4            |
| character_set_filesystem | binary            |
| character_set_results    | utf8mb4            |
| character_set_server    | utf8mb4            |
| character_set_system    | utf8              |
| collation_connection    | utf8mb4_unicode_ci |
| collation_database      | utf8mb4_unicode_ci |
| collation_server        | utf8mb4_unicode_ci |
+--------------------------+--------------------+
 rows in set (0.00 sec)

http://www.linuxidc.com/Linux/2013-05/84360.htm

 

MySQL utf8mb4 字元集:支援 emoji Emoji

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.