gpt4 book ai didi

python - Django mysqlclient 后端在 Windows 中产生 django.db.utils.OperationalError : (2059, )

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:36 25 4
gpt4 key购买 nike

我试图让我的 Django 项目在 Windows 10 计算机上运行,​​但在尝试建立数据库连接时它抛出了一个非常不明确的错误。 In this SO-post the problem was with the authentication , 但在那篇文章中显示了有关错误的详细信息,而不是 <\NULL> ,这几乎没有什么可以继续的。

整个错误如下所示:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000018C3B8761E0>
Traceback (most recent call last):
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\mysql\base.py", line 236, in get_new_connection
return Database.connect(**conn_params)
File "D:\Program\LiquidMarket\venv\lib\site-packages\MySQLdb\__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2059, <NULL>)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\core\management\commands\runserver.py", line 120, in inner_run
self.check(display_num_errors=True)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\core\management\base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\core\management\base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\core\checks\registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\core\checks\model_checks.py", line 27, in check_all_models
errors.extend(model.check(**kwargs))
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\base.py", line 1200, in check
errors.extend(cls._check_fields(**kwargs))
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\base.py", line 1272, in _check_fields
errors.extend(field.check(**kwargs))
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\fields\__init__.py", line 894, in check
errors = super().check(**kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\fields\__init__.py", line 206, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\fields\__init__.py", line 303, in _check_backend_specific_checks
return connections[db].validation.check_field(self, **kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\validation.py", line 21, in check_field
field_type = field.db_type(self.connection)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\models\fields\__init__.py", line 648, in db_type
return connection.data_types[self.get_internal_type()] % data
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\mysql\base.py", line 133, in data_types
if self.features.supports_microsecond_precision:
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\mysql\features.py", line 65, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\mysql\base.py", line 345, in mysql_version
with self.temporary_connection() as cursor:
File "C:\Users\marcu\AppData\Local\Programs\Python\Python36\lib\contextlib.py", line 81, in __enter__
return next(self.gen)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 576, in temporary_connection
cursor = self.cursor()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
return self._cursor()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
self.ensure_connection()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
self.connect()
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "D:\Program\LiquidMarket\venv\lib\site-packages\django\db\backends\mysql\base.py", line 236, in get_new_connection
return Database.connect(**conn_params)
File "D:\Program\LiquidMarket\venv\lib\site-packages\MySQLdb\__init__.py", line 85, in Connect
return Connection(*args, **kwargs)
File "D:\Program\LiquidMarket\venv\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2059, <NULL>)

使用python 3.6.6和mysqlclient 1.3.13,虽然1.3.12也试过了。

数据库设置:

DATABASES = {
'default': {
'ENGINE': "django.db.backends.mysql", # 'mysql.connector.django'
'NAME': 'testdb',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'autocommit': True,
},
},
}

最佳答案

enter image description here

更改新版mysql的加密方式,因为django不支持新的加密方式

关于python - Django mysqlclient 后端在 Windows 中产生 django.db.utils.OperationalError : (2059, <NULL>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51926091/

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