背景條件:
可參考:
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql
我是根據zabbix官網文檔來安裝的,在centos環境下。并且已經安裝成功,進入監控中心后出現如下錯誤:
在安裝好zabbix之后,出現了Zabbix is not running,the information displayed may not be current.
于是我前往/var/log/zabbix-server.log查看錯誤輸出日志。在日志中出現了下面的句子;
connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: YES)
意思是說。連接到數據庫zabbix失敗,拒絕用戶'zabbix'@'localhost'訪問該數據庫(使用密碼 YES)
問題分析
我這里的問題是把DBPassword設置為zabbix,但是在grant all privileges on zabbix.* to zabbix@localhost identified by '<new password for zabbix user on zabbix database>';這句當中后面要填寫的密碼我不是寫成:zabbix。至于是什么,嘿嘿,隱私!兩處的密碼不一樣,導致數據庫訪問被拒絕。在日志中查看到數據庫訪問被拒絕這個輸出。
問題解決方法
將兩處的密碼設置為一樣就可以了,密碼要設置成什么樣子的,由你自己來定,這里給出的例子中密碼設置為:zabbix
1:前往/ect/zabbix/zabbix_server.conf
將該文件下的DBPassword設置為:zabbix
2:重新以mysql root身份登入mysql
在Linux終端下輸入
mysql -u root -p
回車后,會提示你輸入密碼,輸入root用戶得的密碼即可。
然后進入mysql
mysql>
在mysql中輸入
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
然后退出數據庫
quit;
重啟一下數據庫和zabbix-server就行
systemctl restart zabbix-server
systemctl restart httpd