我花了几个小时来解决这些问题,但没有达到任何目的.网上有几个关于这个问题的话题,但没有一个说明是解决这个问题的绝对事情.
我刚刚安装了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.
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的settings.py,错误就是这样
could not connect to server: No such file or …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了 pgadmin iii 并尝试连接服务器。
我配置了我的设置
name:localhost
host: 127.0.0.1
port:5432
username:postgres
Run Code Online (Sandbox Code Playgroud)
但我总是收到这个错误
服务器不接受连接:连接库报告**无法连接到服务器:连接被拒绝 服务器是否在主机“127.0.0.1”上运行并接受端口 5432 上的 TCP/IP 连接?
但是,我在 127.0.0.1 上运行 django 和 python 缺少什么?
mysql也有问题。我无法与他们联系