0

试图在OSX Mountain Lion上设置Postgres/PostGIS以与Django一起使用。然而,有些事情是错误的,我不知道如何解决它。Postgres数据库本地安装/运行

$ createdb geo 
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"? 

$ postgres -D /usr/local/var/postgres 
FATAL: lock file "postmaster.pid" already exists 
HINT: Is another postmaster (PID 221) running in data directory "/usr/local/var/postgres"? 

$ pg_ctl -D /usr/local/var/postgres -l logfile start 
pg_ctl: another server might be running; trying to start server anyway 
server starting 

然后,我发现this gist说,如何解决它在狮子。然而,它并没有为我工作:

$ kill -9 221 
$ pg_ctl -D /usr/local/var/postgres stop 
waiting for server to shut down.... done 
server stopped 

$ pg_ctl -D /usr/local/var/postgres start 
pg_ctl: another server might be running; trying to start server anyway 
server starting 
FATAL: lock file "postmaster.pid" already exists 
HINT: Is another postmaster (PID 1436) running in data directory "/usr/local/var/postgres"? 

的另一种尝试:

$ cd /usr/local/var/postgres 
$ mv postmaster.pid postmaster.backup 
$ pg_ctl -D /usr/local/var/postgres start 
server starting 

$ LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv4 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
WARNING: could not create listen socket for "localhost" 
FATAL: could not create any TCP/IP sockets 

有没有人成功地做到了这一点与美洲狮?如果是这样,我错过了什么?感谢您对此问题的帮助!

回答

1

此消息:

CREATEDB:无法连接到数据库的Postgres:无法连接到 服务器:没有这样的文件或目录 是在本地运行和验收Unix域套接字 连接服务器“/ VAR/pgsql_socket/.s.PGSQL.5432" ?

表明你的PostgreSQL服务器不使用/var/pgsql_socket作为其Unix域套接字目录,这是在服务器和客户端之间的会合点。这很常见,因为只有Apple发布的PostgreSQL和OSX服务器使用该路径。顺便说一下,这就是为什么Apple提供的createdb命令会尝试连接到Apple配置的服务器。

从这一点出发,有很多不同的解决方案可以解决这个问题,但更明显的是使用PostgreSQL安装附带的createdb命令,而不是系统中预安装的命令。

如果你需要进一步的帮助,你应该指定你安装PostgreSQL的方式,因为有很多不同的包提供它,并且它们都使用不同的路径来避免相互之间的践踏。

更新家酿

如果使用BREW,我建议应用在superuser.com答案: How should I set the PATH variable on my Mac so the Hombrew-installed tools are found?

想必你指的是Postgres的+ PostGIS的教程的作者已经改变它很早以前就忘记在他的文本中提及它。

完成后,命令which createdb应返回/usr/local/bin/psql,这是自制软件版本,而不是原始版本/usr/bin/psql,它是Apple版本。

+0

感谢您的想法@Daniel。我使用自制软件安装了PostGRE,并按照[说明](http://pageworthy.com/blog/postgis-on-mountain-lion/)进行操作。你对如何解决这个问题有任何想法,以便我可以在django项目中使用我的PostGREs数据库?感谢您的想法! –

+0

@NickB:查看更新 –

+0

谢谢@Daniel。我跟着从链接后的指令,并把'USR /本地/ bin'以上'USR/bin',但是当我尝试'这createdb'它输出'在/ usr/bin中/ createdb',你上面列出的不是什么。我是否错过了正确链接路径的内容?感谢您的想法! –

相关问题