python system_error ai_generated true

Django数据库操作错误:(2002, "无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)")

django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

ID: python/django-db-connection-error

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-12-01首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

MySQL服务器未运行或套接字路径不正确。

English

MySQL server is not running or socket path is incorrect.

generic

解决方案

  1. 85% 成功率
    Start MySQL service: sudo systemctl start mysql

无效尝试

常见但无效的做法:

  1. 40% 失败

    May still fail if MySQL is not running.

  2. 30% 失败

    Doesn't fix the database server issue.