我在AWS(Ubuntu)中设置一个新服务器来运行Django,使用WSGI,Python 2.7,Apache2和MySQL。
初始页面和管理页面显示正常但我在运行syndcb
后无法登录管理页面。我检查了我的数据库并且表格已成功构建,但当我尝试登录/admin/
页面时,我得到:
/ admin /的OperationalError 无法打开数据库文件 /usr/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py in get_new_connection,第346行
我怀疑这是一个指向sqlite3的缓存,这是错误的。我的app文件夹中没有.pyc文件,这是我settings.py
的相关部分:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'name',
'USER': 'user',
'PASSWORD': 'pw',
'HOST': 'myhost',
'PORT': '3306',
}
}
重启Apache也无法工作。
更新追溯:
Environment:
Request Method: POST
Request URL: http://url/admin/
Django Version: 1.6.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in wrapper
215. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
197. return self.login(request)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in login
330. return login(request, **defaults)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
75. return view(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/views.py" in login
36. if form.is_valid():
File "/usr/lib/python2.7/dist-packages/django/forms/forms.py" in is_valid
129. return self.is_bound and not bool(self.errors)
File "/usr/lib/python2.7/dist-packages/django/forms/forms.py" in errors
121. self.full_clean()
File "/usr/lib/python2.7/dist-packages/django/forms/forms.py" in full_clean
274. self._clean_form()
File "/usr/lib/python2.7/dist-packages/django/forms/forms.py" in _clean_form
300. self.cleaned_data = self.clean()
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/forms.py" in clean
28. self.user_cache = authenticate(username=username, password=password)
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/__init__.py" in authenticate
49. user = backend.authenticate(**credentials)
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/backends.py" in authenticate
16. user = UserModel._default_manager.get_by_natural_key(username)
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/models.py" in get_by_natural_key
167. return self.get(**{self.model.USERNAME_FIELD: username})
File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py" in get
151. return self.get_queryset().get(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py" in get
301. num = len(clone)
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py" in __len__
77. self._fetch_all()
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py" in _fetch_all
854. self._result_cache = list(self.iterator())
File "/usr/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
220. for row in compiler.results_iter():
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in results_iter
710. for rows in self.execute_sql(MULTI):
File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
780. cursor = self.connection.cursor()
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py" in cursor
157. cursor = self.make_debug_cursor(self._cursor())
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py" in _cursor
129. self.ensure_connection()
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
124. self.connect()
File "/usr/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
124. self.connect()
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py" in connect
112. self.connection = self.get_new_connection(conn_params)
File "/usr/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py" in get_new_connection
346. conn = Database.connect(**conn_params)
Exception Type: OperationalError at /admin/
Exception Value: unable to open database file
答案 0 :(得分:0)
我审查了那个&my;' myhost'不在您的resolvconf文件中,所以我将127.0.0.1或您需要连接到您的数据库的IP
如果这是正确的,那么接下来要看的是apache配置和BBDD permisions。