0

I'm on Mac 10.13.6. I restarted my machine and Postgres, which normally starts upon restart, wasn't running. Sadly, I cannot remember how or where I installed it. I'm able to locate instances of "pg_ctl"

sudo find / -name "pg_ctl"

returns

/usr/local/bin/pg_ctl
/usr/local/Cellar/postgresql/9.6.1/bin/pg_ctl
/usr/local/Cellar/postgresql/9.5.0/bin/pg_ctl
/usr/local/Cellar/postgresql/9.6.15/bin/pg_ctl
/usr/local/Cellar/postgresql@9.6/9.6.15/bin/pg_ctl
/usr/local/Cellar/libpq/11.5/bin/pg_ctl
/usr/local/Cellar/postgresql@9.5/9.5.19/bin/pg_ctl

However, I need to tell it a data directory in order for it to start, and I can't figure out how to know the data directory while the server is down. What kind of files should I look for to figure out where the data directory is?

1 Answer 1

0

Check /usr/local/var/postgres

See also answers for Mac in How do I find PostgreSQL's data directory?.

A Linux PGDATA directory looks like:

bash-4.2$ ls -al $PGDATA
total 72
drwx------. 20 postgres postgres  4096 Apr  8 16:44 .
drwx------.  4 postgres postgres    31 Feb 11 23:07 ..
drwx------.  7 postgres postgres    62 Apr  7 21:27 base
-rw-------.  1 postgres postgres    30 Apr  8 16:44 current_logfiles
drwx------.  2 postgres postgres  4096 Apr  8 17:47 global
drwx------.  2 postgres postgres  4096 Apr  7 08:07 log
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_commit_ts
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_dynshmem
-rw-------.  1 postgres postgres  4513 Feb 13 09:21 pg_hba.conf
-rw-------.  1 postgres postgres  1636 Feb 13 09:21 pg_ident.conf
drwx------.  4 postgres postgres    65 Apr  8 17:49 pg_logical
drwx------.  4 postgres postgres    34 Feb 13 09:21 pg_multixact
drwx------.  2 postgres postgres    17 Apr  8 16:44 pg_notify
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_replslot
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_serial
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_snapshots
drwx------.  2 postgres postgres     6 Apr  8 16:44 pg_stat
drwx------.  2 postgres postgres  4096 Apr  8 17:49 pg_stat_tmp
drwx------.  2 postgres postgres    17 Feb 13 09:21 pg_subtrans
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_tblspc
drwx------.  2 postgres postgres     6 Feb 13 09:21 pg_twophase
-rw-------.  1 postgres postgres     3 Feb 13 09:21 PG_VERSION
drwx------.  3 postgres postgres    89 Mar 21 15:02 pg_wal
drwx------.  2 postgres postgres    17 Feb 13 09:21 pg_xact
-rw-------.  1 postgres postgres    88 Feb 13 09:21 postgresql.auto.conf
-rw-------.  1 postgres postgres 24005 Feb 13 09:21 postgresql.conf
-rw-------.  1 postgres postgres    27 Apr  8 16:44 postmaster.opts
-rw-------.  1 postgres postgres   104 Apr  8 16:44 postmaster.pid
-bash-4.2$ 
2
  • Thanks @pifor. That directory does exist. How do I know it's the data directory, iow, are there typical files taht would always be at the root of it? In mine I have files like "pg_hba.conf" and "postgresql.conf".
    – Dave
    Apr 8, 2020 at 15:46
  • See the PGDATA typical output added in my answer. if you have pg_hba.conf and postgresql.conf and all others directories listed: it looks OK.
    – pifor
    Apr 8, 2020 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.