Zabbix 历史记录处出现问号乱码

Zabbix 历史记录处出现问号乱码

历史记录处出现问号乱码

225718664.png

这与zabbix数据库所使用的字符集有关,解决方法如下:

1.查看当前的默认字符集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
mysql>
show create database zabbix;
+----------+-------------------------------------------------------------------+
|
Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
|
zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+-------------------------------------------------------------------+
1
row 
in set (0.00
sec)
#安装时在导入三个sql文件时,zabbix数据库中创建的表的字符集也是latin1
mysql>
show variables like 
'character%';
+--------------------------+----------------------------+
|
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)

2.这是由于字符集不是utf8引起的,现在的解决方法有两种:

当当前zabbix数据库中已存在一定的数据的解决办法

1)备份zabbix数据库

1
[root@zhu1
~]
#
mysqldump -uroot -p123456  zabbix > zabbix.sql

2)修改备份文件

1
[root@zhu1
~]
#
sed -i 's/latin1/utf8/g' zabbix.sql

3)删除zabbix数据库

1
mysql>
drop database zabbix;

4)关闭mysql数据库,设置默认字符集

1
2
3
4
5
6
[root@zhu1
~]
#
vim /etc/my.cnf
[mysqld]
log-bin
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-character-set =
utf8 
#添加该项

5)启动mysql并恢复zabbix数据库

1
[root@zhu1
~]
#
mysql -uroot -p123456 zabbix < zabbix.sql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mysql>
show create database zabbix;
+----------+-----------------------------------------------------------------+
|
Database | Create Database                                                 |
+----------+-----------------------------------------------------------------+
|
zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1
row 
in set (0.00
sec)
mysql>
show variables like 
'character%';
+--------------------------+----------------------------+
|
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)

6)访问页面

232634752.png

2.当安装后发现,则可以:

1
2
3
#1.删除zabbix数据库
#2.设置mysql数据库的默认字符集为utf8
#3.重新创建zabbix数据库并导入三个sql文件

总结:

2

1
2
3
4
5
6
7
8
9
10
11
12
--with-charset=CHARSET
Default
character 
set,
use one of:
binary
armscii8
ascii big5 cp1250 cp1251 cp1256 cp1257
cp850
cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8
greek
hebrew hp8 keybcs2 koi8r koi8u
latin1
latin2 latin5 latin7 macce macroman
sjis
swe7 tis620 ucs2 ujis utf8
--with-extra-charsets=CHARSET,CHARSET,...
Use
charsets 
in addition
to default (none, complex,
all,
or a list selected from the above sets)
#上面这两个是编译安装mysql事对字符集设置的参数,当不进行设置时默认便是latin1,

 

fuck\fuck\(\)\[\]\\\/\fuck”\\$1″fuck\/script>’)} fuck