connection to dat Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: <p><br></p> <p>[root@t1 ~]# tail /tmp/zabbix_server.log <br><span style="color:#3366ff"> 23392:20160303:131022.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local My


[root@t1 ~]# tail /tmp/zabbix_server.log 
 23392:20160303:131022.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 23392:20160303:131022.598 Database is down. Reconnecting in 10 seconds.
 23392:20160303:131032.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 23392:20160303:131032.598 Database is down. Reconnecting in 10 seconds.
 23392:20160303:131042.599 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 23392:20160303:131042.599 Database is down. Reconnecting in 10 seconds.
 23392:20160303:131052.599 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 23392:20160303:131052.599 Database is down. Reconnecting in 10 seconds.
 23392:20160303:131102.600 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 23392:20160303:131102.600 Database is down. Reconnecting in 10 seconds.

[root@t1 ~]# find / -name mysql.sock
/tmp/mysql.sock

解决:

ln -s  /tmp/mysql.sock /var/lib/mysql/mysql.sock

重启zabbix_server
重启mysql

正常运行:



如下

zabbix连不上数据库

[root@localhost etc]# tail -f /var/log/zabbix_server.log 
1267:20130722:195451.493 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195451.493 Database is down. Reconnecting in 10 seconds.
1267:20130722:195501.494 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195501.494 Database is down. Reconnecting in 10 seconds.
1267:20130722:195511.494 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195511.494 Database is down. Reconnecting in 10 seconds.
1267:20130722:195521.495 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195521.495 Database is down. Reconnecting in 10 seconds.
1267:20130722:195531.495 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195531.496 Database is down. Reconnecting in 10 seconds.
1267:20130722:195541.496 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195541.496 Database is down. Reconnecting in 10 seconds.
1267:20130722:195551.498 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1267:20130722:195551.498 Database is down. Reconnecting in 10 seconds.


解决办法:
[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! 

参考:
http://www.cnblogs.com/seasonsstory/p/3209785.html


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
1月前
|
SQL 关系型数据库 MySQL
|
2月前
|
关系型数据库 MySQL 网络安全
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
|
2月前
|
关系型数据库 MySQL 数据库
docker启动mysql多实例连接报错Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
docker启动mysql多实例连接报错Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
198 0
|
3月前
|
数据采集 关系型数据库 MySQL
大数据-业务数据采集-FlinkCDC The MySQL server is not configured to use a ROW binlog_format
大数据-业务数据采集-FlinkCDC The MySQL server is not configured to use a ROW binlog_format
44 1
|
3月前
|
关系型数据库 MySQL Java
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
|
4月前
|
SQL Oracle 关系型数据库
MySQL、SQL Server和Oracle数据库安装部署教程
数据库的安装部署教程因不同的数据库管理系统(DBMS)而异,以下将以MySQL、SQL Server和Oracle为例,分别概述其安装部署的基本步骤。请注意,由于软件版本和操作系统的不同,具体步骤可能会有所变化。
319 3
|
4月前
|
安全 关系型数据库 MySQL
【Python】已解决:pymysql.err.OperationalError:(2003 “Can’t connect to MySQL server on ‘localhost’ ([WinEr
【Python】已解决:pymysql.err.OperationalError:(2003 “Can’t connect to MySQL server on ‘localhost’ ([WinEr
566 1
|
4月前
|
关系型数据库 MySQL 数据库
2003-Can`t connect to Mysql server on ‘154.8.165.152‘(10038)
2003-Can`t connect to Mysql server on ‘154.8.165.152‘(10038)
|
1月前
|
网络协议 测试技术 网络安全
Python编程-Socket网络编程
Python编程-Socket网络编程
|
4月前
|
网络协议 开发者 Python
深度探索Python Socket编程:从理论到实践,进阶篇带你领略网络编程的魅力!
【7月更文挑战第25天】在网络编程中, Python Socket编程因灵活性强而广受青睐。本文采用问答形式深入探讨其进阶技巧。**问题一**: Socket编程基于TCP/IP,通过创建Socket对象实现通信,支持客户端和服务器间的数据交换。**问题二**: 提升并发处理能力的方法包括多线程(适用于I/O密集型任务)、多进程(绕过GIL限制)和异步IO(asyncio)。**问题三**: 提供了一个使用asyncio库实现的异步Socket服务器示例,展示如何接收及响应客户端消息。通过这些内容,希望能激发读者对网络编程的兴趣并引导进一步探索。
56 4
下一篇
无影云桌面