Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a password for PostgreSQL in postgreapp?

I am using postgresapp for the PostgreSQL and without password I was able to connect to the database and perform operations. I am curious to learn about the password. Also I use Postico as Interface. Open to any suggestions.

like image 268
Venkateshreddy Pala Avatar asked Oct 25 '25 00:10

Venkateshreddy Pala


1 Answers

The default for Postgres.app is to have no password and set trust-level authentication in pg_hba.conf. To change this, you need to do the following:

  • Alter the IP address and mask for host all all 127.0.0.1/32 trust as needed in pg_hba.conf, and change authentication method from trust to password or md5 (or whatever your requirements are)
  • Set the password for the desired user(s) with ALTER USER <username> WITH PASSWORD '<password>';
  • Reload the conf with SELECT pg_reload_conf()

Note your pg_hba.conf file is usually located in ~/Library/Application Support/Postgres/var-12 -- the sure-fire way to know is by querying SHOW data_directory in your psql prompt

like image 157
richyen Avatar answered Oct 26 '25 16:10

richyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!