无法使用psycopg2连接postgreSQL
发布时间:2020-12-13 16:41:04 所属栏目:百科 来源:网络整理
导读:这是我第一次找不到有关技术问题的答案 这是我的问题: conn=psycopg2.connect(database="mydb",user="postgres",password="123",port=5432)Traceback (most recent call last): File "stdin",line 1,in modulepsycopg2.OperationalError: could not connect
这是我第一次找不到有关技术问题的答案
这是我的问题: >> conn=psycopg2.connect(database="mydb",user="postgres",password="123",port=5432) Traceback (most recent call last): File "<stdin>",line 1,in <module> psycopg2.OperationalError: 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"? >我的postgreSQL正在运行 List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges ---------------+----------+----------+------------+------------+----------------------- checkdatabase | postgres | UTF8 | en_US.utf8 | en_US.utf8 | mydb | postgres | UTF8 | en_US.utf8 | en_US.utf8 | postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 | template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres 非常感谢!
psycopg2使用的libpq期望Postgres套接字位于/ var / run / postgresql /中,但是当您从源代码安装Postgres时,默认情况下在/ tmp /中。
检查是否有/tmp/.s.PGSQL.5432文件,而不是/var/run/postgresql/.s.PGSQL.5432。尝试: conn=psycopg2.connect( database="mydb",host="/tmp/",password="123" ) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |