zabbix在mysql改密码后前台php报错无法登入

因刚开始安装zabbix时,在mysql中创建的同名zabbix账号弱口令,修改密码后,前台php一直报错:

[Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

查看zabbix_server.log:

25877:20140304:160513.718 [Z3005] query failed: [1317] Query execution was interrupted [select h.hostid,h.host,h.name,t.httptestid,
t.name,t.variables,t.agent,t.authentication,t.http_user,t.http_password,t.http_proxy,t.retries from httptest t,hosts h where t.hosti
d=h.hostid and t.nextcheck<=1393920313 and mod(t.httptestid,1)=0 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.mai
ntenance_status=0 or h.maintenance_type=0)]
25877:20140304:160513.718 [Z3005] query failed: [2006] MySQL server has gone away [select min(t.nextcheck) from httptest t,hosts h
where t.hostid=h.hostid and mod(t.httptestid,1)=0 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.maintenance_status
=0 or h.maintenance_type=0)]
25877:20140304:160513.719 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)

25877:20140304:160513.718 [Z3005] query failed: [1317] Query execution was interrupted [select h.hostid,h.host,h.name,t.httptestid,
t.name,t.variables,t.agent,t.authentication,t.http_user,t.http_password,t.http_proxy,t.retries from httptest t,hosts h where t.hosti
d=h.hostid and t.nextcheck<=1393920313 and mod(t.httptestid,1)=0 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.mai
ntenance_status=0 or h.maintenance_type=0)]
25877:20140304:160513.718 [Z3005] query failed: [2006] MySQL server has gone away [select min(t.nextcheck) from httptest t,hosts h
where t.hostid=h.hostid and mod(t.httptestid,1)=0 and t.status=0 and h.proxy_hostid is null and h.status=0 and (h.maintenance_status
=0 or h.maintenance_type=0)]
25877:20140304:160513.719 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)

更新zabbix_server的配置文件中mysql的数据源中密码:

vi zabbix_server.conf
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword='new password'
DBSocket=/var/lib/mysql/mysql.sock
AlertScriptsPath=/usr/local/oracle/

但前台php还继续报错,仍然无法登入:

Database error: Error connecting to database [Access denied for user 'zabbix'@'localhost' (using password: YES)]

百思不得其解,是不是前台php还有数据源的配置呢?果然:

vi /etc/zabbix/web/zabbix.conf.php

<?php
// Zabbix GUI configuration file
global $DB;

$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'new password';

// SCHEMA is relevant only for IBM_DB2 database
$DB['SCHEMA'] = '';

$ZBX_SERVER = 'ZABBIX_SERVER_IP';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'ZABBIX_SERVER_HOST';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>

前台php终于能登录进去了!

此条目发表在linux分类目录,贴了标签。将固定链接加入收藏夹。