我花了几个小时来解决这些问题,但没有达到任何内容。网络上有关于这个问题的几个主题,但他们都没有说要解决这个问题。Postgresql和django - Unix域套接字
我刚刚安装了postgresql,以便在我的django项目中使用它。
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2", # Add "postgresql_psycopg2", "postgresql", "mysql", "sqlite3" or "oracle".
"NAME": "name", # Or path to database file if using sqlite3.
"USER": "postgres", # Not used with sqlite3.
"PASSWORD": "pass", # 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.
}
}
这是我的settings.py和错误是
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
有没有人有一个关于它的解决方案吗?
为什么你的'HOST'和'PORT'是空的?如果你在本地运行你的django服务器,那么你必须至少指定'HOST':'localhost' – stalk
你的系统和版本是什么?你是如何安装Postgresql的 - 从源代码,从分发包或从安装程序?您是否检查过Postgres服务真的在运行? Postgres套接字在哪里?'/ var/run/postgresql/.s.PGSQL.5432'或'/ tmp/.s.PGSQL.5432'或在其他地方。你能用'psql'连接吗?对于几个小时的工作,你不提供太多的信息来处理。 – Tometzky
Debian 6。主机和端口是空的,因为我在本地主机上无需填写它 – user1407540