Re: Please Help me with connecting my PostgreSQL
От | Daniele Varrazzo |
---|---|
Тема | Re: Please Help me with connecting my PostgreSQL |
Дата | |
Msg-id | AANLkTik20Fgimxh0TJFABHfGcyGQ0G+xYABh=pX2VW28@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Please Help me with connecting my PostgreSQL (Adrian Klaver <adrian.klaver@gmail.com>) |
Ответы |
Re: Please Help me with connecting my PostgreSQL
|
Список | psycopg |
On Thu, Mar 31, 2011 at 2:33 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote: > On Thursday, March 31, 2011 5:54:34 am Lasntonpeng wrote: >> It's the first time that I can't find the answer about some tech problems >> >> Here's my problems: >> >>conn=psycopg2.connect(database="mydb", user="postgres", >> >> password="123",port=5433) >> >> 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"? > > Two problems. The first is the one Karsten already mentioned about the difference > on ports. Second you have not specified a host so Psycopg is trying the local > socket. If you are trying to connect from a machine other than the other one > with the Postgres server it is not going to find the socket. Also the socket > connection may have a restriction in pg_hba.conf that would prevent a > connection. To connect to a database on the local machine, the quick answer is: add host=127.0.0.1 to the connection string, which makes it connect to the network socket instead of the unix socket. And I mean "127.0.0.1", not "localhost". All the gory details are in the pg_hba.conf documentation. -- Daniele
В списке psycopg по дате отправления: