0

I have postgresql running (/opt/local/lib/postgresql90/bin).

The data base is set up @ /Users/demet8/postgres/data.

I check to make sure postgresql is running with

ps aux | grep postgres

demet8 9851 0.0 0.1 614276 1184 ?? Ss 12:40PM 0:00.24 postgres: autovacuum launcher process
demet8 9850 0.0 0.0 614020 436 ?? Ss 12:40PM 0:00.91 postgres: wal writer process
demet8 9849 0.0 0.0 614020 496 ?? Ss 12:40PM 0:01.22 postgres: writer process
demet8 9847 0.0 0.1 614020 2248 s002 S 12:40PM 0:00.61 /opt/local/lib/postgresql90/bin/postgres -D /Users/demet8/postgres/data demet8 11127 0.0 0.0 599820 468 s002 S+ 2:05PM 0:00.00 grep postgres demet8 9852 0.0 0.0 610092 368 ?? Ss 12:40PM 0:00.26 postgres: stats collector process

I go back into: /opt/local/lib/postgresql90/bin & now try to start the db with ./pg_ctl start. This is the error msg I get:

pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information.

Any suggestions on to what I can be doing wrong. I googled around the web for answers & I haven't found a solution.

demet8
  • 1,089
  • 5
  • 14
  • 26
  • If it is already started why do you want to start it again? – Clodoaldo Neto Jul 19 '11 at 18:22
  • I want to be able to enter the db once it's running. I used ./pg_ctl start a couple of times to get into the db & it worked. For some reason it doesn't work now. I also tried $su - then su -postgres & the db responds back with "sorry." I'll have to keep trying until I figure this thing out. Thanks. – demet8 Jul 19 '11 at 18:46
  • What do you mean by "to enter the db" and "to get into the db"? – Milen A. Radev Jul 19 '11 at 19:11
  • If you want to start an interactive session then the command is `psql` – Clodoaldo Neto Jul 19 '11 at 19:22
  • I wanted to get an interactive session going is what I was trying to explain & I should have clarified that better. I just figured it out. I entered ./psql postgres & it worked. Thank you for your help. – demet8 Jul 19 '11 at 19:36

2 Answers2

1
$ su -
# su - postgres

Proceed from there.

Clodoaldo Neto
  • 118,695
  • 26
  • 233
  • 260
0

I know this question is already answered but, if you are new to Postgres and seeing similar issues, try the below commands to resolve the error pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information.

1. su - postgres
2. find / -name pg_ctl --> gives you the location where pg_ctl present, in my case it is there in `/usr/lib/postgresql/11/bin/`
3. /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main
Suresh
  • 277
  • 1
  • 4
  • 22