我按照说明进行操作这个问题和答案。
我的C:\Program Files (x86)\PostgreSQL\9.4\data\postgresql.conf
读物:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
我的C:\Program Files (x86)\PostgreSQL\9.4\data\pg_hba.conf
读物是:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/32 trust
# IPv6 local connections:
host all all ::1/128 md5
然而,当我运行以下命令时:
conn_string = 'postgresql://user:[email protected]/postgres'
from sqlalchemy import *
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
import traceback
import pandas as pd
engine = create_engine(conn_string, echo=True)
engine.connect()
我收到以下错误:
OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "my.ip" and accepting
TCP/IP connections on port 5432?
用户名和密码直接从预先存在的脚本复制而来,使用起来localhost
非常完美。
自从做出这些更改后,我已经完全重启了电脑。
有人对我可能遗漏的内容有任何意见吗?