关于MyCAT字符集的验证

MyCAT默认字符集是UTF8

下面通过查看日志来验证不同的MySQL客户端字符集和服务器字符集对于MyCAT的影响。

日志中与字符集有关的主要有三部分:

1. 初始化MyCAT连接池

2. 心跳检测

3. 在执行SQL语句时的连接同步。

因为MyCAT实现的是三节点的读写分离和自动切换,以下修改的均是localhost节点上MySQL实例的字符集,其它两个点(192.168.244.146和192.168.244.144)均没有修改。默认为

mysql> show variables like 'character_set_%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) 

一、当客户端字符集(character_set_client)为utf8,服务端字符集(character_set_server)为latin1。

mysql> show variables like 'character_set_%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)

MyCAT的日志输出如下:

1. 初始化连接池

2. 心跳检测

关于MyCAT字符集的验证

3. 在执行SQL语句时的连接同步。

二、当客户端字符集为latin1,服务端字符集也为latin1。

mysql> show variables like 'character_set_%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)

MyCAT的日志输出如下:

1. 初始化MyCAT连接池

2. 心跳检测

关于MyCAT字符集的验证

3. 在执行SQL语句时的连接同步。

三、当客户端字符集为latin1,服务端字符集也为utf8。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5b97701045ea1a991e2fb953f911f02b.html