Postgres 安装 : 我使用 macports 并按照以下命令安装 postgres。这是链接 https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#macports
$ sudo port install postgresql83-server
无法创建数据库 : 当我尝试使用以下命令从终端应用程序创建数据库时
$ createdb mydb
我收到此错误消息
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
你能帮忙吗!!
最佳答案
这是 Mac OS X 上的一个众所周知的问题。
Apple 将他们自己的 PostgreSQL 版本与某些 OS X 版本捆绑在一起。这具有不同的默认套接字位置。如果 Apple 的 psql
和 libpq
首先在您的 PATH
和 DYLD_LIBRARY_PATH
上,那么您将使用旧版本的默认为 Apple 套接字位置的工具。
您应该修复您的 PATH
以便 MacPorts bin
目录位于第一位,因此正确的 psql
和 pg_config
首先被发现。或者你可以:
psql -h /tmp
或:
psql -h localhost
...但是由于使用不匹配版本的 psql
会导致奇怪的结果,因此最好修复您的 PATH
。
在 Stack Overflow 上有很多关于此的信息,Google 搜索 "OS X""postgresql""could not connect to server: No such file or directory"
是相当有用的信息。
另外:请不要安装 PostgreSQL 8.3。它已经过时且不受支持。安装 PostgreSQL 9.2,当前版本。为什么您可能会使用 8.3?
关于django - 无法从 OSX 终端应用程序创建 postgres 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17378696/