zabbix连接不上mysql
8705:20160517:181535.420 connection to database 'zabbix' failed: Can't connect to MySQL server on 'host' (13)8705:20160517:181535.420 database is down: reconnecting in 10 seconds
数据库和ZABBIX在同一台服务器上。
# cat /etc/hosts
127.0.0.1host
192.168.8.120 host
# grep -v "#" /etc/zabbix/zabbix_server.conf|grep DB
DBHost=host
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
# cat /etc/zabbix/web/zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'host';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Zabbix;
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = '192.168.8.120';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'host';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
手工连接没有问题。
# mysql -u zabbix -p'zabbix'
mysql: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> 端口是不是不对,你手工链接没指定端口,那默认应该是3306,但你配置的是1005...呢,这种问题,自己多试就能找到原因。 或者你mysql授权做了限制吧。show grants for user看看呢。 $DB['PORT'] = '0';
你数据库端口没有配置啊 这里写了0默认是3306 2楼说的那是zabbix的端口没有错 配置文件中端口0好像指的就是采用默认的3306端口,我记得马哥说,如果MYSQL和zabbix server安装在同一台主机上时,好像要更改zabbix_server.conf中DBSocket选项,指定MYSQL的socket文件位置,你看看是不是这个原因。 看起来像用户表的权限限制。 show grants for user@'host'; 看看。 本帖最后由 oushitianxia915 于 2016-06-14 17:00 编辑
回复 6# h101com
权限是有的啊,另外跟端口没关系,是0 的时候我也启过ZABBIX
show grants for zabbix@host;
+---------------------------------------------------------------------+
| Grants for zabbix@host |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'host' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
回复 2# expert1
1005是ZABBIX的服务端口
不知道你已经解决没有。将host改为% 试下,。另外,这种问题自己简单测试下就可以发现问题,不用到这边的来问。:mrgreen: 回复 7# oushitianxia915
不知道你已经解决没有。将host改为% 试下,。另外,这种问题自己简单测试下就可以发现问题,不用到这边的来问。:mrgreen: