MySQL 数据库字符集设置
(1)编辑 vim /etc/my.cnf 配置文件,在相应段中加入相应的参数字符集,修改完毕后,重启 MySQL 服务务即可。(2)MySQL 命令行中运行如下指令。
·
修改字符集有两种方法:
(1)编辑 vim /etc/my.cnf 配置文件,在相应段中加入相应的参数字符集,修改完毕后,重启 MySQL 服务务即可
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[root@localhost ~]# systemctl restart mariadb.service
[root@localhost ~]# mysql
MariaDB [(none)]> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
(2)MySQL 命令行中运行如下指令
MariaDB [(none)]> SET character_set_client = utf8;
MariaDB [(none)]> SET character_set_results = utf8;
MariaDB [(none)]> SET character_set_connection = utf8;
MariaDB [(none)]> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
更多推荐
已为社区贡献1条内容
所有评论(0)