Chinaunix

标题: zabbix连接不上mysql [打印本页]

作者: oushitianxia915    时间: 2016-05-17 18:17
标题: zabbix连接不上mysql
  8705:20160517:181535.420 [Z3001] connection to database 'zabbix' failed: [2003] 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.1  host
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: [Warning] 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>
作者: expert1    时间: 2016-05-18 16:16
端口是不是不对,你手工链接没指定端口,那默认应该是3306,但你配置的是1005...呢,这种问题,自己多试就能找到原因。
作者: expert1    时间: 2016-05-18 16:17
或者你mysql授权做了限制吧。show grants for user看看呢。
作者: qw10371006    时间: 2016-05-19 09:55
$DB['PORT']     = '0';
你数据库端口没有配置啊 这里写了0  默认是3306   2楼说的那是zabbix的端口没有错
作者: 寂寞暴走伤    时间: 2016-06-06 22:00
配置文件中端口0好像指的就是采用默认的3306端口,我记得马哥说,如果MYSQL和zabbix server安装在同一台主机上时,好像要更改zabbix_server.conf中DBSocket选项,指定MYSQL的socket文件位置,你看看是不是这个原因。
作者: h101com    时间: 2016-06-13 16:17
看起来像用户表的权限限制。 show grants for user@'host'; 看看。
作者: oushitianxia915    时间: 2016-06-14 16:59
本帖最后由 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)
   
作者: oushitianxia915    时间: 2016-06-14 17:02
回复 2# expert1

1005是ZABBIX的服务端口


   
作者: h101com    时间: 2016-06-24 11:02
不知道你已经解决没有。将host改为% 试下,。另外,这种问题自己简单测试下就可以发现问题,不用到这边的来问。
作者: h101com    时间: 2016-06-24 11:02
回复 7# oushitianxia915


    不知道你已经解决没有。将host改为% 试下,。另外,这种问题自己简单测试下就可以发现问题,不用到这边的来问。
作者: expert1    时间: 2016-08-18 17:34
楼上眼尖,应该是这个问题。很奇怪,官方文档写的一清二楚,对着copy,咋会出现奇怪的问题呢。
作者: stduolc    时间: 2017-02-19 15:26
楼主,你后来解决这个问题了么?我也遇到相同的问题,也是用cli链接的上,但是zabbix自己连不上。
作者: sditmaner    时间: 2017-02-19 18:09
回复 2# expert1
作者: wjw870907    时间: 2018-02-06 18:43
host是什么,你写127.0.0.1呗,然后grant
作者: phenix688    时间: 2018-08-12 00:04
数据库zabbix密码是zabbix,为什么在zabbixGUI配置文件里的dbpassword=Zabbix?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2