Postgresql – postgres: could not find the database system

homebrewmac os xpostgresql

If I try to run the postgres command, I get:

2020-12-29 00:14:53.213 GMT [34374] LOG:  skipping missing configuration file "/usr/local/pgsql/data/postgresql.auto.conf"
postgres: could not find the database system
Expected to find it in the directory "/usr/local/pgsql/data",
but could not open file "/usr/local/pgsql/data/global/pg_control": No such file or directory

How can I find out what config file is telling postgres to look at /usr/local/pgsql/data?

In my case, postgres was installed on OSX via Homebrew.

Best Answer

While I don't know what specific config file is pointing to that location, it can be specified when you run the initdb command, which it's sounding like you may not have run yet, given the error you're seeing.

If you just installed a new/upgrade postgres instance, you'll probably want to use a new data directory from whatever your old instance was using (i.e. you can just run the initdb command with no additional params, and it will use the default /usr/local/pgsql/data location which, apparently, is not yet in use for your machine), then you can export/import the old data if you still need it.