In general, we add the configuration in the configuration file my.cnf:
[Client]default-character-set = UTF8 [mysqld]default-character-set = utf8character-set-server = Utf8init-connect = ' Set NAMES UTF8 ' collation-server = utf8_general_ci #可选的
Specify a character set when creating a database:
Create database Zabbix character set UTF8 collate utf8_bin;
View the database's character set in MySQL connection state:
Show CREATE Database Zabbix_office; #查看创建数据库的字符集
Show variables like ' character% '; #查看mysql默认的字符集
To modify a character set:
SET character_set_client = UTF8; SET character_set_connection = UTF8; SET character_set_results = UTF8; SET character_set_database = UTF8; SET character_set_server = UTF8; SET collation_connection = UTF8; SET collation_database = UTF8; SET collation_server = UTF8;
Client connection still see is garbled, this time to see whether the client's character set and the service side of the character set is consistent, if inconsistent, to modify the client character set:
SET NAMES ' UTF8 ';
Modify the default character set for the created database, this is not a good idea, you can only export data, delete the library and then rebuild the library to specify the default character set.
Create database Zabbix character set UTF8 collate utf8_bin;
This article from "Wang Jiadong elder brother" blog, declined reprint!
Summary of problems with MySQL character set