Zabbix

Zabbix 連接 MySQL 錯誤

  • March 8, 2017

通過嘗試打開 Zabbix 2.2.2 伺服器 Web 界面,我遇到了一個錯誤:

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

這是日誌:

870:20140716:181121.327 Starting Zabbix Server. Zabbix 2.2.2 (revision 42525).
  870:20140716:181121.327 ****** Enabled features ******
  870:20140716:181121.328 SNMP monitoring:           YES
  870:20140716:181121.328 IPMI monitoring:            NO
  870:20140716:181121.328 WEB monitoring:            YES
  870:20140716:181121.329 VMware monitoring:          NO
  870:20140716:181121.329 Jabber notifications:      YES
  870:20140716:181121.329 Ez Texting notifications:  YES
  870:20140716:181121.329 ODBC:                       NO
  870:20140716:181121.329 SSH2 support:               NO
  870:20140716:181121.330 IPv6 support:              YES
  870:20140716:181121.330 ******************************
  870:20140716:181121.330 using configuration file: /usr/local/etc/zabbix22/zabbix_server.conf
  870:20140716:181121.335 current database version (mandatory/optional): 02020000/02020000
  870:20140716:181121.335 required mandatory version: 02020000
  871:20140716:181121.345 server #1 started [configuration syncer #1]
  872:20140716:181121.346 server #2 started [db watchdog #1]
  870:20140716:181121.395 server #0 started [main process]
  873:20140716:181121.424 server #3 started [poller #1]
  874:20140716:181121.452 server #4 started [poller #2]
  875:20140716:181121.479 server #5 started [poller #3]
  876:20140716:181121.509 server #6 started [poller #4]
  877:20140716:181121.535 server #7 started [poller #5]
  878:20140716:181121.564 server #8 started [unreachable poller #1]

沒有關於連接錯誤的消息。這是配置文件:

### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
DBHost=localhost

### Option: DBName
#       Database name.
#       For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix
### Option: DBSchema
#       Schema name. Used for IBM DB2.
#
# Mandatory: no
# Default:
# DBSchema=

### Option: DBUser
#       Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword
#       Database password. Ignored for SQLite.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zabbix

### Option: DBSocket
#       Path to MySQL socket.
#
# Mandatory: no
# Default:
#DBSocket=/tmp/mysql.sock
### Option: DBPort
#       Database port when not using local socket. Ignored for SQLite.
#
# Mandatory: no
# Range: 1024-65535
# Default (for MySQL):
# DBPort=3306

我可以使用該使用者名和密碼從 shell 連接:

root@zabbix-srv:/usr/home/ishayahu # mysql -u zabbix -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 167
Server version: 5.5.37 Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show grants for 'zabbix'@'localhost';
+------------------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@localhost                                                                                            |
+------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY PASSWORD '*DEEF4D7D88CD046ECA02A80393B7780A63E7E789' |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost'                                                             |
+------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

謝謝你的幫助!

您已在此處粘貼伺服器配置文件 - 前端使用不同的文件。請查看前端目錄中的 zabbix.conf.php 文件,並確保其中的密碼與伺服器配置文件中的密碼一致。

引用自:https://serverfault.com/questions/613023