【问题标题】:getting ConnectionDoesNotExist error when attempting to migrate mysql database in django尝试在 django 中迁移 mysql 数据库时出现 ConnectionDoesNotExist 错误
【发布时间】:2018-12-25 03:52:13
【问题描述】:

这是我在 django settings.py 中用于数据库的代码:

DATABASES= {
    'defualt': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'cameronkc',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': 'localhost',
        'PORT': ''
    }
}

这是我在命令提示符下执行 >python manage.py migrate 时收到的错误

django.db.utils.ConnectionDoesNotExist: The connection default doesn't exist

【问题讨论】:

  • 尝试添加 'PORT': 3306 并重试。 3306 是 mysql 的默认端口。而且您知道您的用户、密码和“名称”数据库是正确的吗?

标签: python mysql django database connection


【解决方案1】:

您在 DATABASES 字典中拼错了 default。将'defualt' 更改为'default'

【讨论】:

  • 伙计,没有什么比一个简单的错字更能浪费我几个小时的时间了。学过的知识。我很感激你。
  • 你用过IDE吗?
猜你喜欢
  • 1970-01-01
  • 2019-02-14
  • 2016-09-04
  • 2021-04-11
  • 2020-08-24
  • 2021-04-09
  • 2016-06-14
  • 2015-07-10
  • 2021-02-28
相关资源
最近更新 更多