zabbix ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var

Database error
–Error connecting to database: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
报错截图如下:

在这里插入图片描述
解决方法:
报错信息说是连接不上数据库,我们先看下数据的状态,
使用命令:systemctl status mariadb
如下信息:
[root@linux7 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 六 2020-03-07 08:46:43 CST; 2min 28s ago
Process: 4078 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Main PID: 4078 (code=exited, status=0/SUCCESS)

3月 07 08:35:12 linux7.7oracle12.2 systemd[1]: Starting MariaDB database server…
3月 07 08:35:13 linux7.7oracle12.2 mariadb-prepare-db-dir[4044]: Database MariaDB is probably initialize…e.
3月 07 08:35:13 linux7.7oracle12.2 mariadb-prepare-db-dir[4044]: If this is not the case, make sure the …r.
3月 07 08:35:13 linux7.7oracle12.2 mysqld_safe[4078]: 200307 08:35:13 mysqld_safe Logging to ‘/var/log/…g’.
3月 07 08:35:13 linux7.7oracle12.2 mysqld_safe[4078]: 200307 08:35:13 mysqld_safe Starting mysqld daemo…sql
3月 07 08:35:19 linux7.7oracle12.2 systemd[1]: Started MariaDB database server.
3月 07 08:46:42 linux7.7oracle12.2 systemd[1]: Stopping MariaDB database server…
3月 07 08:46:43 linux7.7oracle12.2 systemd[1]: Stopped MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

结论:发现数据库状态是inactive (dead),尝试启动数据库。
[root@linux7 ~]# systemctl start mariadb
[root@linux7 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2020-03-07 08:52:22 CST; 4s ago
Process: 5609 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 5575 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 5607 (mysqld_safe)
Tasks: 32
CGroup: /system.slice/mariadb.service
├─5607 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─5770 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql…

3月 07 08:52:20 linux7.7oracle12.2 systemd[1]: Starting MariaDB database server…
3月 07 08:52:20 linux7.7oracle12.2 mariadb-prepare-db-dir[5575]: Database MariaDB is probably initialize…e.
3月 07 08:52:20 linux7.7oracle12.2 mariadb-prepare-db-dir[5575]: If this is not the case, make sure the …r.
3月 07 08:52:21 linux7.7oracle12.2 mysqld_safe[5607]: 200307 08:52:21 mysqld_safe Logging to ‘/var/log/…g’.
3月 07 08:52:21 linux7.7oracle12.2 mysqld_safe[5607]: 200307 08:52:21 mysqld_safe Starting mysqld daemo…sql
3月 07 08:52:22 linux7.7oracle12.2 systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

刷新zabbix页面,发现已经可以打开了,问题解决。
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值