mysql.sock 软连接,无法通过套接字'/tmp/mysql.sock连接到本地MySQL服务器

When I attempted to connect to a local MySQL server during my test suite, it

fails with the error:

OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

However, I'm able to at all times, connect to MySQL by running the command line

mysql program. A ps aux | grep mysql shows the server is running, and

stat /tmp/mysql.sock confirm that the socket exists. Further, if I open a

debugger in except clause of that exception, I'm able to reliably connect

with the exact same parameters.

This issue reproduces fairly reliably, however it doesn't appear to be 100%,

because every once in a blue moon, my test suite does in fact run without

hitting this error. When I attempted to run with sudo dtruss it did not reproduce.

All the client code is in Python, though I can't figure how that'd be relevant.

Switching to use host 127.0.0.1 produces the error:

DatabaseError: Can't connect to MySQL server on '127.0.0.1' (61)

解决方案sudo /usr/local/mysql/support-files/mysql.server start

This worked for me. However, if this doesnt work then make sure that mysqld is running and try connecting.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值