gpt4 book ai didi

python - (2002, "Can' t 通过套接字 '/var/lib/mysql/mysql.sock' (2) 连接到本地 MySQL 服务器”)

转载 作者:行者123 更新时间:2023-11-29 08:43:46 24 4
gpt4 key购买 nike

我正在使用 apache 运行基于 django 的 Web 应用程序。我能够从 python 和 linux shell 连接到 mysql,但是,当我运行服务器时,我收到以下错误。我哪里做错了?

OperationalError at /

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

Request Method: GET
Request URL: http://dev.ls.co.uk/
Django Version: 1.3
Exception Type: OperationalError
Exception Value:

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

Exception Location: build/bdist.linux-x86_64/egg/MySQLdb/connections.py in __init__, line 187
Python Executable: /usr/bin/python
Python Version: 2.4.3

最佳答案

根据mysql.com上的这个帖子:

There are two things that could go wrong here:

  1. You don't have permissions to access the directory /var/lib/mysql/whatever.sock because mysql is the owner of the folder or
  2. /path/whatever.sock doesn't exist.

首先,您应该知道 apache 以什么用户身份运行:尝试 top 命令来找出用户。然后,使用 id thatusername 命令来确定它所在的组。

然后,您可以阅读article about debugging this kind of problem

关于python - (2002, "Can' t 通过套接字 '/var/lib/mysql/mysql.sock' (2) 连接到本地 MySQL 服务器”),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13048617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com