“错误2002(HY000):无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器”错误和解决方案...

当尝试通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器时,可能会遇到错误2002(HY000)。本文提供三个解决方案:启动服务、检查套接字路径和检查数据目录权限,以解决该问题。
摘要由CSDN通过智能技术生成

MySQL service provides different connection methods. We generally prefer TCP/IP way where connection is established over Network Socket. There is alternative way named Socket which is connected over local system. During connection we may get error like Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ . In this tutorial we will look to solve this problem.

MySQL服务提供了不同的连接方法。 通常,我们更喜欢通过网络套接字建立连接的TCP / IP方式。 还有另一种名为Socket的方法,它通过本地系统连接。 在连接期间,我们可能会收到类似无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器的错误 在本教程中,我们将寻求解决此问题。

解决方案1 ​​–启动服务 (Solution 1 – Start The Service)

Socket is created by the MySQL service and if the service is not the started the socket will not created. So starting the service is the first step to solve this problem. We will use systemctl  command.

套接字是由MySQL服务创建的,如果服务不是启动的,则不会创建套接字。 因此,启动服务是解决此问题的第一步。 我们将使用systemctl命令。

$ sudo systemctl start mysql.service

AND check service status

并检查服务状态

$ sudo systemctl status mysql.service
Solution 1 - Start The Service
Solution 1 – Start The Service
解决方案1 ​​–启动服务

解决方案2 –检查套接字路径

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值