zabbix插入中文单词作为项密钥失败

时间:2013-03-20 01:21:08

标签: php mysql utf-8 zabbix

当我向Zabbix插入一个包含中文的项目并将最终放入mysql时,浏览器会显示:

Error cannot update item
Error in query [SELECT i.key_,h.host FROM items i,hosts h WHERE i.hostid=h.hostid AND ((i.hostid=10085 AND i.key_='logrt[\"/home/test/event.*.log\",\"失败\",\"GBK\",,]')) AND i.itemid!='23439' LIMIT 1 OFFSET 0] [Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=']
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given 
[include/db.inc.php:572] mysql_free_result() expects parameter 1 to be resource, boolean given 

[include/db.inc.php:573]

我认为它失败了,因为zabbix不能接受除UTF-8之外的其他编码,但我不知道如何更改它。感谢

1 个答案:

答案 0 :(得分:0)

好的,我发现了问题。看来,当我创建zabbix数据库时,我使用了默认字符集,即latin1_swedish_ci但实际上它应该是utf8。所以我用以下sql重新创建数据库:

create database zabbix character set utf8

然后一切正常!