zs2*_*020 1 python mysql django
这个线程没有太大帮助:在查询期间丢失了与MySQL服务器的连接.
我将max_allowed_packet增加到16M,max_connections增加到9999.但是,我仍然收到此错误:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (2013, 'Lost connection to MySQL server during query')
Run Code Online (Sandbox Code Playgroud)
它有点随机发生,任何人都可以对它有所了解吗?
一些可能性(部分来自https://serverfault.com/questions/29597/what-does-mysql-error-2013-mean/30036#30036):
另一种可能性是由于缺少索引,庞大的数据集或您正在使用的表引擎(可能是InnoDB或MyISAM)的限制,查询本身非常昂贵.确定这个问题的一个好方法是找到导致问题的QuerySet,从QuerySet获取原始sql(请参阅从Django QuerySet获取SQL),然后在您选择的mysql shell中运行带有EXPLAIN的查询.
| 归档时间: |
|
| 查看次数: |
6118 次 |
| 最近记录: |