您的位置:首页 > 博客中心 > 数据库 >

mysql 相关环境配置

时间:2022-03-14 01:14

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 = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘SET NAMES utf8mb4‘

$ sudo service mysql restart
$ mysql -uroot -p # login and check
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 |
+--------------------------+--------------------+
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)

 

热门排行

今日推荐

热门手游