我播種後在MySQL服務器已消失(代碼2006)
How to enable MySQL client auto re-connect with MySQLdb?
我有同樣的問題,我用pythonanywhere.com,當我寫p.save()我有錯誤,如下面。
它說了一些關於更新MySQL來解決它,但我不知道我需要寫什麼代碼或shell命令。
你能幫我嗎?
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 570, in save_base
with transaction.commit_on_success_unless_managed(using=using, savepoint=False):
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py", line 280, in __enter__
connection.set_autocommit(False)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 340, in set_autocommit
self._set_autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 243, in autocommit
_mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')
這是關於該主題最直接的答案(包括其他問題),但是我會注意到,在做一個非常大的delete()時,Django會斷開這個跟蹤回溯。 – WAF