由网友(微笑,只是为了防止泪水的滑落。)分享简介:Exception Type: OperationalError at /Exception Value: (1049, "Unknown database 'database'")目前,我想这样的:At the moment i tried this:DATABASES = {'default': {'ENGI...
Exception Type: OperationalError at /
Exception Value: (1049, "Unknown database 'database'")
目前,我想这样的:
At the moment i tried this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'database', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '****', # Not used with sqlite3.
'HOST': '/var/lib/mysql/database/', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '80', # Set to empty string for default. Not used with sqlite3.
}
}
如果我不指定主机我得到这个错误:
If i don't specify a host i get this error:
OperationalError at /
(2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/database' (13)")
难道是一些与权限?
Can it be something with permissions?
在此先感谢:)
推荐答案
首先,创建在MySQL数据库。 二,修改默认的连接如这样的。
First, create the database on mysql. Second, edit your default conection like this.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'MY_DATABASE_NAME',
'USER': 'root',
'PASSWORD': 'MY_PASSWORD',
}
}
最后运行的SyncDB。
finally run your syncdb.
./ manage.py的SyncDB
./manage.py syncdb
相关推荐
最新文章