PostgreSQL Mountain Lion socket issue

前端 未结 4 1359
旧巷少年郎
旧巷少年郎 2020-12-25 13:39

I\'ve been trying to set up PostgreSQL on my system (OSX 10.8, clean install), but I\'m running into trouble with using psql, createdb, etc. I\'ve

4条回答
  •  悲&欢浪女
    2020-12-25 14:02

    According to the error message, the psql command that appears first in the $PATH has /tmp as the hard-coded default unix socket directory.

    Since the actual directory is in fact /var/pgsql_socket, you should tell it explicitly rather than relying on the default:

    $ psql -h /var/pgsql_socket [other options]
    

    The same applies to other client-side commands like createdb, dropdb, createuser...

    If you don't want to specify -h each time, it can be put into the PGHOST environment variable.

    Some people also solve this by using TCP connections to localhost rather than using the Unix socket directory.

    The root cause of this issue would be that after installing PostgreSQL on Mac OS X, the system ends up having two different instances of the postgres client set (the libpq library, psql and other associated utilities), one that is bundled with MacOS and the other that comes with the PostgreSQL installer.

    Therefore yet another method is to change your $PATH so that the psql installed with PostgreSQL gets choosen before the one installed with the system (presumably /usr/bin/psql).

提交回复
热议问题