zabbix connection to database 'zabbix' failed:

在启动zabbix时启动失败,查看日志:

[root@localhost zabbix]# tailf /tmp/zabbix_server.log
 24661:20170523:203250.916 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 24661:20170523:203250.916 database is down: reconnecting in 10 seconds
 24661:20170523:203300.916 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 24661:20170523:203300.916 database is down: reconnecting in 10 seconds
 24661:20170523:203310.917 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 24661:20170523:203310.917 database is down: reconnecting in 10 seconds
 24661:20170523:203320.918 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 24661:20170523:203320.918 database is down: reconnecting in 10 seconds
 24661:20170523:203330.920 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 24661:20170523:203330.920 database is down: reconnecting in 10 seconds


发现日志链接不上

[root@localhost zabbix]# ll /var/lib/mysql/mysql.sock
ls: cannot access /var/lib/mysql/mysql.sock: No such file or directory
[root@localhost zabbix]# ll /var/lib/mysql
ls: cannot access /var/lib/mysql: No such file or directory

可以知道是/var/lib/mysql/mysql.sock不存在

在系统中查找mysql.sock文件:

[root@localhost zabbix]# find / -name mysql.sock
find: ?.run/user/1000/gvfs?. Permission denied
/tmp/mysql.sock
可以知道是在/tmp/下,这个时候有两种方式解决这个问题:

1)做mysql.sock的链接

[root@localhost lib]# mkdir /var/lib/mysql
[root@localhost lib]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
[root@localhost lib]# /etc/rc.d/init.d/mysqld restart
Shutting down MySQL... SUCCESS! 
Starting MySQL SUCCESS! 

2)修改zabbix_server.conf中的mysql.sock的配置

vim /etc/zabbix/zabbix_server.conf
DBSocket=/tmp/mysql.sock
再重启zabbix就好

[root@localhost ~]# vi /var/log/zabbix/zabbix_server.log 29773:20250725:145659.307 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145659.307 database is down: reconnecting in 10 seconds 29773:20250725:145709.308 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145709.308 database is down: reconnecting in 10 seconds 29773:20250725:145719.309 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145719.309 database is down: reconnecting in 10 seconds 29773:20250725:145729.310 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145729.310 database is down: reconnecting in 10 seconds 29773:20250725:145739.310 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 29773:20250725:145739.310 database is down: reconnecting in 10 seconds 29773:20250725:145749.311 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145749.311 database is down: reconnecting in 10 seconds 29773:20250725:145752.039 Got signal [signal:15(SIGTERM),sender_pid:30435,sender_uid:0,reason:0]. Exiting ... 29773:20250725:145752.040 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 29773:20250725:145752.040 Cannot connect to the database. Exiting... 30441:20250725:145752.049 Starting Zabbix Server. Zabbix 4.0.50 (revision c40ad3289ad). 30441:20250725:145752.050 ****** Enabled features ****** 30441:20250725:145752.050 SNMP monitoring: YES 30441:20250725:145752.050 IPMI monitoring: YES 30441:20250725:145752.050 Web monitoring: YES 30441:20250725:145752.050 VMware monitoring: YES 30441:20250725:145752.050 SMTP authentication: YES 30441:20250725:145752.050 Jabber notifications: YES 30441:20250725:145752.050 Ez Texting notifications: YES 30441:20250725:145752.050 ODBC: YES 30441:20250725:145752.050 SSH support: YES 30441:20250725:145752.050 IPv6 support: YES 30441:20250725:145752.050 TLS support: YES 30441:20250725:145752.050 ****************************** 30441:20250725:145752.050 using configuration file: /etc/zabbix/zabbix_server.conf 30441:20250725:145752.052 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145752.052 database is down: reconnecting in 10 seconds 30441:20250725:145802.053 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145802.053 database is down: reconnecting in 10 seconds 30441:20250725:145812.053 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145812.054 database is down: reconnecting in 10 seconds 30441:20250725:145822.055 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145822.055 database is down: reconnecting in 10 seconds 30441:20250725:145832.056 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145832.056 database is down: reconnecting in 10 seconds 30441:20250725:145842.057 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145842.057 database is down: reconnecting in 10 seconds 30441:20250725:145852.058 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO) 30441:20250725:145852.058 database is down: reconnecting in 10 seconds
07-26
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值