gpt4 book ai didi

mysql - Django 迁移失败,(2013, 'Lost connection to MySQL server at\' 读取初始通信包\')

转载 作者:搜寻专家 更新时间:2023-10-30 22:24:28 29 4
gpt4 key购买 nike

公司工作在NameCheap下购买了域名(无Root权限)

我现在只需要设置数据库和网页就可以正常工作了

我公司系统使用:

Apache 版本:2.4.38

MySQL版本:10.1.38-MariaDB-cll-lve

架构:x86_64

操作系统:Linux

python :3.7

Django :2.1.7

但是当我运行 python manage.py migrate

我有这个错误:

Traceback (most recent call last):
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2013, 'Lost connection to MySQL server at \'reading initial communication packet\', system error: 2 "No such file or directory"')

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

Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 59, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/home/letsilap/virtualenv/IOT/3.7/lib/python3.7/site-packages/MySQLdb/connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server at \'reading initial communication packet\', system error: 2 "No such file or directory"')

我在 StackOverflow 上做了一些搜索:

Error during Django "Running migrations": django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')

Trouble closing and reopening MySQL connection after catching/handling django.db.utils.OperationalError (2013, Lost connection to server)

但不是很有帮助

对该主题的进一步挖掘使我相信 MYSQL 数据库拒绝访问我的 Django 应用程序。

我可以尝试这个理论,因为我根本无法访问 MYSQL 设置

总结一下;我需要在 django 应用程序上迁移,但运行命令时出错。

请帮忙,如果你能帮我解决这个问题,我真的很感激。

最佳答案

我是编码新手。也许你犯了初学者的错误?

单词不匹配?包括,大写下划线?

我不知道我是否在帮忙。

只是建议

关于mysql - Django 迁移失败,(2013, 'Lost connection to MySQL server at\' 读取初始通信包\'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55605306/

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