zabbix歷史記錄處出現問號亂碼解決方法

其實根本上是覺得在啓動mysql前沒有修改配置文件:
修改一下mysql配置文件
vim /etc/my.cnf //修改或增長以下內容
[mysql]
default-character-set = utf8
[mysqld]
character_set_server = utf8php

若是是已經安裝過zabbix,已經開始運行了,能夠按照搜索文檔配置下,下面貼:mysql

zabbix是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。 zabbix能監視各類網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各類問題。
本文爲你們講解的是Zabbix歷史記錄處出現問號亂碼解決方法,感興趣的同窗參考下.sql

歷史記錄處出現問號亂碼,以下圖數據庫

http://img.phperz.com/data/img/20141106/1415270193_5832.pngvim

這與zabbix數據庫所使用的字符集有關,解決方法以下:安全

1.查看當前的默認字符集服務器

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數據庫中已存在必定的數據的解決辦法socket

1)備份zabbix數據庫分佈式

[root@zhu1 ~]# mysqldump -uroot -p123456 zabbix > zabbix.sql
2)修改備份文件

[root@zhu1 ~]# sed -i 's/latin1/utf8/g' zabbix.sql
3)刪除zabbix數據庫

mysql> drop database zabbix;

4)關閉mysql數據庫,設置默認字符集

[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數據庫

[root@zhu1 ~]# mysql -uroot -p123456 zabbix < zabbix.sql
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)訪問頁面

http://img.phperz.com/data/img/20141106/1415270193_2979.png

2.當安裝後發現,則能夠:

#1.刪除zabbix數據庫
#2.設置mysql數據庫的默認字符集爲utf8
#3.從新建立zabbix數據庫並導入三個sql文件

總結:

--with-charset=CHARSETDefault character set, use one of:binaryarmscii8 ascii big5 cp1250 cp1251 cp1256 cp1257cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8greek hebrew hp8 keybcs2 koi8r koi8ulatin1 latin2 latin5 latin7 macce macromansjis 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,

相關文章
相關標籤/搜索