django.db.utils.OperationalError 未知的连接地址如何寻源?
django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'192.168.10.1' (using password: YES)")
运行Django 项目报错,上面的192.168.**.1 不知道地址哪里来的,调试后,如图中可以看到实际要连接的是10.0.74 网段的地址
请问怎么解决,或者怎么找到192.168 的地址哪里来的
Watching for file changes with StatReloader2022-07-20 14:54:40,327 INFO Watching for file changes with StatReloader
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
return Database.connect(**conn_params)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 588, in connect
self._request_authentication()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 863, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 936, in _process_auth
pkt = self._read_packet()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 676, in _read_packet
packet.raise_for_error()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error
err.raise_mysql_exception(self._data)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'192.168.10.1' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check_migrations()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/core/management/base.py", line 459, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 53, in __init__
self.build_graph()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 216, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
return Database.connect(**conn_params)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 327, in __init__
self.connect()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 588, in connect
self._request_authentication()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 863, in _request_authentication
auth_packet = self._process_auth(plugin_name, auth_packet)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 936, in _process_auth
pkt = self._read_packet()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/connections.py", line 676, in _read_packet
packet.raise_for_error()
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/protocol.py", line 223, in raise_for_error
err.raise_mysql_exception(self._data)
File "/Users/jason/INOC/venv/lib/python3.8/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'192.168.10.1' (using password: YES)")
回答:
看下 setting.py 文件中的关于数据库的配置。
以上是 django.db.utils.OperationalError 未知的连接地址如何寻源? 的全部内容, 来源链接: utcz.com/p/938517.html