Question Locked

How can I start PostgreSQL server on Mac OS X

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi

I had forgotten to run the initdb command.

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 the Ruby on 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 wasn't any pg_hba.conf file (only file 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' # w

2 replies

by prioryplop0q edited

This is what worked for me as well. Before initdb, I had to also chown the postgres dir (chown _your username on your comp_ usr/local/var/postgres), then initdb. After that the server starts automatically when you restart (if you followed Homebrew's instructions for that) or manually pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start.

I had almost the exact same issue, and you cited the initdb command as being the fix. This was also the solution for me, but I didn't see that anyone posted it here, so for those who are looking omegle.club for it:

initdb /usr/local/var/postgres -E utf8

This discussion is closed to new replies.