异常值:(2002,“无法通过套接字连接到本地MySQL服务器'/var/run/mysqld/mysqld.sock'(111)”)

时间:2014-09-05 10:13:49

标签: python mysql django sockets mysql-python

大家好我在部署服务器上一次又一次地收到此错误。该网站似乎工作了一段时间,但然后它再次崩溃并显示此错误

这是追溯`

Environment:


Request Method: GET
Request URL: http://getfbstuff.com/

Django Version: 1.6.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'downloader',
 'ckeditor',
 'django.contrib.sitemaps')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _cache_controlled
  38.             response = viewfunc(request, *args, **kw)
File "/home/getfbstuff/public_html/getfbstuff.com/fb/downloader/views.py" in index
  23.   if seo:
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __nonzero__
  100.         self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fetch_all
  854.             self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
  220.         for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in results_iter
  709.         for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  781.         cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in cursor
  157.             cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in _cursor
  129.         self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
  124.                 self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
  99.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
  124.                 self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in connect
  112.         self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py" in get_new_connection
  435.         conn = Database.connect(**conn_params)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py" in Connect
  81.     return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py" in __init__
  187.         super(Connection, self).__init__(*args, **kwargs2)

Exception Type: OperationalError at /
Exception Value: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)")`

请帮助我,我无法弄清楚我做错了什么。我按照这些步骤配置了mysql和django www.saltycrane.com/blog/2008/07/how-set-django-mysql-ubuntu-hardy/

我在本地机器上没有遇到这样的问题。 提前致谢

1 个答案:

答案 0 :(得分:1)

我选择的设置是正确的,问题的原因是因为一旦访问者数量增加,我的RAM就用完了,这就是为什么每当我重新启动服务器时,问题都消失了。

所以现在我将RAM从512MB增加到1GB,从那时起就没有任何错误。