首页 > 代码库 > mysql 相关环境配置

mysql 相关环境配置

1. mysql 版本要求 5.5 以上, 否则不支持 emoji 表情.

$ sudo apt-get install mysql-server$ sudo vim /etc/mysql/my.cnf  # charset utf8mb4. mysql 5.5 required[client]default-character-set = utf8mb4[mysql]default-character-set = utf8mb4[mysqld]character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect=SET NAMES utf8mb4$ sudo service mysql restart$ mysql -uroot -p # login and checkmysql> 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 |+--------------------------+--------------------+10 rows in set (0.00 sec)# security grant mysql> use mysql;mysql> delete from user where user = ‘‘;Query OK, 2 rows affected (0.00 sec)

 

mysql 相关环境配置