No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? QPSQL: Unable to connect"
Either PostreSQL isn't running, or (most likely on Mac OS X) your Qt linked to the libpq
of the old PostgreSQL supplied as part of Mac OS X, and you're running a newer version you installed yourself. You should specify host
as /tmp
to force the unix_socket_directory
to where your Pg is running. If that's not it, check the correct location by connecting with psql
and using SHOW unix_socket_directory
or (newer versions) SHOW unix_socket_directories
. You should also SHOW port;
to see what port PostgreSQL is listening on; this applies for unix socket directories as well as TCP/IP.
The only difference with the second snippet is that you're specifying a hostname, so you're connecting to localhost
over TCP/IP, not unix sockets.
The rest of your problems are probably being caused by not understanding the effect that Apple's pre-installed version of PostgreSQL has on your system. I strongly suspect you're running CREATE USER
,ALTER USER
, CREATE DATABASE
etc commands on one database, while your Qt program is connecting to a different PostgreSQL instance.
(My feelings toward Apple for creating this mess are not printable here).
What you need to do is:
Confirm the
unix_socket_directory
andport
number the PostgreSQL instance you installed is running on; and thenUse those details in your Qt program.