Postgres数据库本地安装/运行 [英] Postgres Database Local Installation / Running

查看:439
本文介绍了Postgres数据库本地安装/运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在OSX Mountain Lion上设置Postgres/PostGIS以与Django一起使用.但是,出了点问题,我不确定如何解决.

Trying to setup Postgres / PostGIS on OSX Mountain Lion to use with Django. However, something is wrong and I am not sure how to fix it.

$ 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

然后我发现了此要点,上面说了如何将其固定在狮子身上.但是,它对我不起作用:

Then I found this gist that said how to fix it on lion. However it did not work for me:

$ 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

有人用山狮成功做到了吗?如果是这样,我想念什么?感谢您在此问题上的帮助!

Has anyone successfully done this with mountain lion? If so, what am I missing? Thanks for your help with this issue!

推荐答案

此消息:

createdb:无法连接到数据库postgres:无法连接到 服务器:没有这样的文件或目录 服务器是否在本地运行并接受 Unix域套接字"/var/pgsql_socket/.s.PGSQL.5432"上是否连接?

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"?

表示PostgreSQL服务器未使用/var/pgsql_socket作为其Unix域套接字目录,该目录是服务器与客户端之间的 rendez-vous点.这是很常见的,因为只有Apple随OSX服务器一起提供的PostgreSQL才使用该路径.顺便说一句,这就是Apple随附的createdb命令尝试连接到Apple配置的服务器的原因.

indicates that your PostgreSQL server doesn't use /var/pgsql_socket as its Unix domain socket directory, which is the rendez-vous point between the server and the client. This is quite common, since only PostgreSQL shipped by Apple with OSX server uses that path. Incidentally, this is why the createdb command as shipped by Apple tries to connect to the server as configured by Apple.

从那时起,有很多不同的解决方案可以解决该问题,但是更明显的解决方案是使用PostgreSQL安装随附的createdb命令,而不是系统中预先安装的命令.

From that point, there are a lot of different solutions to work around the problem, but the more obvious one would be to use the createdb command that comes with your PostgreSQL installation instead of the one that is preinstalled in your system.

如果您需要进一步的帮助,则应指定安装PostgreSQL的方式,因为有很多不同的软件包可以提供PostgreSQL,并且它们都使用不同的路径来避免彼此践踏.

Should you need further help with that, you should specify how you installed PostgreSQL, because there are quite a few different packages that provide it, and they all use different paths to avoid trampling over each other.

更新自制软件

如果使用brew,我建议在superuser.com上应用答案: 如何在Mac上设置PATH变量,以便找到Hombrew安装的工具?

If using brew, I suggest to apply the answer on superuser.com: How should I set the PATH variable on my Mac so the Hombrew-installed tools are found?

大概您所指的Postgres + Postgis教程的作者很早以前就更改了它的PATH,却忘了在他的文字中提及它.

Presumably the author of the Postgres+Postgis tutorial you're referring to has changed its PATH long ago and forgot to mention it in his text.

完成后,命令which createdb应该返回/usr/local/bin/psql这是自制版本,而不是初始的/usr/bin/psql是Apple版本.

Once done, the command which createdb should return /usr/local/bin/psql which is the homebrew version instead of the initial /usr/bin/psql which is the Apple version.

这篇关于Postgres数据库本地安装/运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆