Verification of the MyCAT Character Set
The default Character Set of MyCAT is UTF8.
The following describes how to check the log to verify the effect of different MySQL client character sets and server character sets on MyCAT.
There are three main parts of logs related to character sets:
1. initialize the MyCAT connection pool
2. Heartbeat Detection
3. Connection synchronization during SQL statement execution.
Because MyCAT implements read/write splitting and automatic failover for three nodes, the following changes are the character set of the MySQL instance on the localhost node, and the other two points (192.168.244.146 and 192.168.244.144) are not modified. Default Value:
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)
1. When the character set of the client (character_set_client) is utf8, the character set of the server (character_set_server) is 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 log output is as follows:
1. initialize the connection pool
2. Heartbeat Detection
3. Connection synchronization during SQL statement execution.
2. When the client character set is latin1, the server character set is also 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 log output is as follows:
1. initialize the MyCAT connection pool
2. Heartbeat Detection
3. Connection synchronization during SQL statement execution.
3. When the client character set is latin1, the server character set is also utf8.
mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | latin1 || character_set_connection | latin1 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | latin1 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)
MyCAT log output is as follows:
1. initialize the MyCAT connection pool
2. Heartbeat Detection
3. Connection synchronization during SQL statement execution.
4. When the client character set is utf8, the server character set is also utf8.
mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| 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)
MyCAT log output is as follows:
1. initialize the MyCAT connection pool
2. Heartbeat Detection
3. Connection synchronization during SQL statement execution.
Summary:
Initialize the MyCAT connection pool. The heartbeat detection characters are related to the server character set, that is, the value set by character_set_server. When the character set of the MySQL instance of localhost is changed to utf8, because the character set of the MySQL instance on the 192.168.244.146 and 192.168.244.144 nodes does not change, during heartbeat detection, the character set of localhost is utf8, the other two nodes are still latin1.
The synchronous connection is related to the character set of the client, that is, the value set by character_set_client.
This article permanently updates the link address: