python - 在syncdb django python期间出错

标签 python mysql django

当我尝试执行以下操作时出现错误 python 管理.py 同步数据库。

错误如下图

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 231, in execute
    self.validate()
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 103, in get_validation_errors
    connection.validation.validate_field(e, opts, f)
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field
    db_version = self.connection.get_server_version()
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 411, in get_server_version
    self.cursor()
  File "/Library/Python/2.6/site-packages/django/db/backends/__init__.py", line 306, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 387, in _cursor
    self.connection = Database.connect(**kwargs)
  File "/Library/Python/2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/Library/Python/2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)")

知道原因是什么吗?

最佳答案

更仔细地阅读您的调试消息。 错误是“无法通过套接字连接到本地 MySQL 服务器”。你应该在 settings.py 检查你的连接参数

关于python - 在syncdb django python期间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17907109/

相关文章:

php - 获取最后 x 条记录的最佳方法是什么?使用 MySQL 限制和 ORDER DESC?

mysql - 如何使用 mysql 删除和更新 JSON 中子对象的一个​​对象

django - Django:模型验证错误ManytoManyField

python - 新列中跨轴 1 的 Pandas 求和和最大值

python - 允许用户使用 django 表单创建 "appointment"

Python - 被类和实例变量混淆

c# - 将 MySQL 查询转换为 Sqlite (SUBSTRING_INDEX)

jquery - 自动完成字段未在 django-autocomplete-light 表单集中呈现

python - 如何过滤掉有约会(外键关系)的个人资料?

python - 为什么我收到错误 : No module named 'email.MIMEMultipart' ?