java mac postgresql,如何在Mac OS X上启动PostgreSQL服务器?

FINAL UPDATE:

I had forgotten to run the initdb command.

< /FINAL UPDATE>

by running this command

ps auxwww | grep postgres

I see that postgres is not running

> ps auxwww | grep postgres

remcat 1789 0.0 0.0 2434892 480 s000 R+ 11:28PM 0:00.00 grep postgres

this raises the question:

How do I start the postgresql server?

update:

>pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

server starting

sh: /usr/local/var/postgres/server.log: No such file or directory

update 2:

The touch was not successful so I did this instead:

> mkdir /usr/local/var/postgres

> vi /usr/local/var/postgres/server.log

> ls /usr/local/var/postgres/

server.log

But when I try to start rails server, I still see this:

Is the server running on host "localhost" and accepting

TCP/IP connections on port 5432?

update 3:

> pg_ctl -D /usr/local/var/postgres status

pg_ctl: no server running

update 4:

I found that there WAS NO pg_hba.conf (only pg_hba.conf.sample) so I modified the sample and renamed it (to remover the .sample). Here are the contents:

# IPv4 local connections:

host all all 127.0.0.1/32 trust

# IPv6 local connections:

host all all ::1/128 trust

but I don't understand this:

> pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

server starting

> pg_ctl -D /usr/local/var/postgres status

pg_ctl: no server running

also:

sudo find / -name postgresql.conf

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

update 5:

sudo pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Password:

pg_ctl: cannot be run as root

Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

update 6:

this seems odd:

> egrep 'listen|port' /usr/local/var/postgres/postgresql.conf

egrep: /usr/local/var/postgres/postgresql.conf: No such file or directory

though, I did do this:

>sudo find / -name "*postgresql.conf*"

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

/usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample

/usr/share/postgresql/postgresql.conf.sample

so I did this:

egrep 'listen|port' /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample

#listen_addresses = 'localhost' # what IP address(es) to listen on;

#port = 5432 # (change requires restart)

# supported by the operating system:

# %r = remote host and port

so I tried this:

> cp /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf

> cp /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf

still getting the same "Is the server running?" message.

解决方案

The Homebrew package manager includes launchctl plists to start automatically. For more information run brew info postgres.

Start manually:

pg_ctl -D /usr/local/var/postgres start

Stop manually:

pg_ctl -D /usr/local/var/postgres stop

Start automatically:

"To have launchd start postgresql now and restart at login:"

brew services start postgresql

What is the result of pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start?

What is the result of pg_ctl -D /usr/local/var/postgres status?

Are there any error messages in the server.log?

Make sure tcp localhost connections are enabled in pg_hba.conf:

# IPv4 local connections:

host all all 127.0.0.1/32 trust

Check the listen_addresses and port in postgresql.conf:

egrep 'listen|port' /usr/local/var/postgres/postgresql.conf

#listen_addresses = 'localhost' # what IP address(es) to listen on;

#port = 5432 # (change requires restart)

Cleaning up

Postgres was most likely installed via Homebrew, Fink, MacPorts or the EnterpriseDB installer.

Check the output of the following commands to determine which package manager it was installed with:

brew && brew list|grep postgres

fink && fink list|grep postgres

port && port installed|grep postgres

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值