MySQL设置字符集

本文测试环境为Windows Server 2008 R2系统,MySQL版本为MariaDB 10.1.32。mysql

首先查看服务器字符集设置。sql

C:\Users\Administrator>mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.1.32-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like 'character%';
+--------------------------+--------------------------------+
| Variable_name            | Value                          |
+--------------------------+--------------------------------+
| character_set_client     | gbk                            |
| character_set_connection | gbk                            |
| character_set_database   | latin1                         |
| character_set_filesystem | binary                         |
| character_set_results    | gbk                            |
| character_set_server     | latin1                         |
| character_set_system     | utf8                           |
| character_sets_dir       | C:\xampp\mysql\share\charsets\ |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)

修改服务器默认字符集设置。其余设置也能够修改Variable_name和Value设置。数据库

MariaDB [(none)]> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)

本文设置完成后查询结果以下。服务器

MariaDB [(none)]> show variables like 'character%';
+--------------------------+--------------------------------+
| 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       | C:\xampp\mysql\share\charsets\ |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)

MariaDB [(none)]>

注意:不一样客户端链接数据库查询结果不必定彻底相同。测试

相关文章
相关标签/搜索