use*_*774 1 python mysql django syncdb
我试图让我的第一个Django项目在Windows上运行,但是我收到一条错误消息:
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)")
Run Code Online (Sandbox Code Playgroud)
我从命令行创建了我的数据库:
-- 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'
Run Code Online (Sandbox Code Playgroud)
我的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.
}
Run Code Online (Sandbox Code Playgroud)
}
任何人都可以对我做错了吗?
小智 5
您的数据库名为GlobalXdb,但在此行中...
#give user permissions to db
GRANT ALL ON django.* TO 'django_user'@'localhost'
Run Code Online (Sandbox Code Playgroud)
您在名为django的数据库上授予django_user权限.
授予正确数据库权限GlobalXdb应解决您的问题.
| 归档时间: |
|
| 查看次数: |
1765 次 |
| 最近记录: |