1049"未知数据库'数据库'" Django的MySQL不能连接 [英] 1049, "Unknown database 'database' " django mysql can't connect
本文介绍了1049"未知数据库'数据库'" Django的MySQL不能连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
这篇关于1049"未知数据库'数据库'" Django的MySQL不能连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文