连接到数据库“zabbix”失败:[1045]用户“zabbix”@“localhost”访问被拒绝(使用密码:NO)

问题描述 投票:0回答:1

我是zabbix的新用户。 更新 zabbix 后(从 Zabbix 4.0.8 到 Zabbix 4.2.5),我遇到了 Web 界面问题。

The frontend does not match Zabbix database. Current database version (mandatory/optional): 4000000/4000006. Required mandatory version: 4020000. Contact your system administrator.

我打开日志文件并发现:

10344:20221123:151903.222 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
 10344:20221123:151903.222 database is down: reconnecting in 10 seconds

我检查了/usr/share/zabbix/conf/zabbix.conf.php

global $DB;

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

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'zabbix-test';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

如果我用密码登录mysql,它就可以工作。

mysql -u zabbix -h localhost --database=zabbix -p

没有密码则无法使用。

mysql -u zabbix -h localhost --database=zabbix
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: NO)

据我了解,问题是zabbix在登录时不使用密码。

我已经尝试过:

mysql> grant all privileges on zabbix.* to zabbix@localhost;

尝试更新代理:

apt-get install --only-upgrade zabbix-proxy-mysql

0 upgraded, 0 newly installed, 0 to remove and 109 not upgraded.
database zabbix
1个回答
0
投票

zabbix更新后zabbix_server.conf已更改。 我发现我的数据库密码被注释掉了。

  DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword

我写了密码,它起作用了。

DBPassword=yourpassword
© www.soinside.com 2019 - 2024. All rights reserved.