I've forgotten my postgres password for my local install (Ubuntu 20.04).

I have postgres installed and running

henry@henry-Apollo:/$ service postgresql status
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Thu 2021-08-19 18:16:09 BST; 2 days ago
   Main PID: 1924 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 18895)
     Memory: 0B
     CGroup: /system.slice/postgresql.service

Aug 19 18:16:09 henry-Apollo systemd[1]: Starting PostgreSQL RDBMS...
Aug 19 18:16:09 henry-Apollo systemd[1]: Finished PostgreSQL RDBMS.

I'm trying to find pg_hba.conf based on a couple of posts I've seen that explain a process to reset the password.

sudo find / -type d -name "pg_hba.conf"
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied

I cannot find the file. How do I reset the password please.

Thanks


Solution 1:

You most likely won't find it this way:

find / -type d -name "pg_hba.conf"

-type d means you're asking for a directory and this would most likely be something like pg_hba.conf.d. So you'd rather look for a plain file:

find / -type f -name "pg_hba.conf"

Or just don't use the -type parameter at all and see what you find then.