我試圖讓我的第一個Django項目工作,在Windows上,但我得到的是一條錯誤信息:蟒蛇manage.py執行syncdb錯誤
File "c:\users\[username]\appdata\local\temp\easy_install-pazcre\MySQL_python-1.2.3-py2.7- win32.egg.tmp\MySQLdb\connections.py", line 187, in __init__ mysql_exceptions.OperationalError: (1045, "Access denied for user 'django_user'@'localhost' (using password: YES)")
我創建了數據庫中的命令行:
-- create the database
CREATE DATABASE GlobalXdb CHARACTER SET utf8;
-- create user
CREATE USER 'django_user'@'localhost' IDENTIFIED BY 'thepassword';
-- give user permissions to db
GRANT ALL ON django.* TO 'django_user'@'localhost'
我settings.py
文件包含:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'GlobalXdb', # Or path to database file if using sqlite3.
'USER': 'django_user', # Not used with sqlite3.
'PASSWORD': 'thepassword', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
任何人都可以闡明我做錯了什麼嗎?
Ahhhhhh !!!!這解決了這個問題。 感謝您的幫助。 – user1261774 2012-03-11 20:10:52
Django允許您爲數據庫定義多個數據庫訪問權限。然後,您可以指定運行syncd db時要使用的數據庫訪問權限。看到我下面的答案.... – 2014-09-09 23:59:48