I installed postgresql on my Mac through homebrew. It said it didn't create a postgres account, but is using an account with my username instead. However, running the command psql
fails because when I type in my password, it says it's wrong. I've retried it to make sure I'm not typing it wrong. So what's the password it gave me?
-
1See also this question: http://stackoverflow.com/questions/7695962/postgresql-password-authentication-failed-for-user-postgres?rq=1 – DNA May 20 '14 at 20:49
-
4It usually creates an account with your username but no password assigned. – tadman May 20 '14 at 21:00
-
What is the exact error message? – jjanes May 20 '14 at 21:57
-
1@tadman I noticed my install did create an account with my user name however when it prompts for passwords and I just hit enter (assuming this would satisfy no password), it just repeats the prompt for a password. Are you aware of way to actually authenticate as the default user or is this not possible? – Kevin Dark May 17 '20 at 04:33
8 Answers
As per tadman's comment, Homebrew postgres currently creates an account with the same name as the installing user, but no password. E.g. after my initial install (username david
):
$ psql postgres
psql (12.2)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
david | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

- 48,006
- 27
- 136
- 235
-
10Homebrew is constantly prompting for a password for any user (whether psql -U postgres or just psql postgres), fresh after installation. There does not seem to be a user without a password. – Cheetaiean Jun 04 '20 at 20:25
-
-
-
Try using `psql -U postgres` followed by `postgres` as the password. – Pratik Parmar Aug 08 '23 at 08:08
When installing on a mac via homebrew, the default user that is created is named the same as your mac's user account. There is no password, and running psql
should get you in.
If not, you likely ALSO have the postgres application installed. If you uninstall the application it will no longer have issues with clashing users.

- 171
- 2
- 6
-
5If you're getting the PG error: `database "
" does not exist` - homebrew will install the DB user as – jester66 Aug 08 '22 at 10:42but keep the default DB name as 'postgres' - so logging in with `psql -d postgres` will work.
There are two different "accounts" here:
The OS X user that owns the PostgreSQL files and processes. When you installed PostgreSQL, you used your own user account for that.
The PostgreSQL user that can log in to the PostgreSQL database. By default, that user is internal to your PostgreSQL instance and has nothing to do with any OS X user.
For psql, you need #2. Immediately after installation, there should be a user named "postgres" with no password that has full administrative privileges - try logging in with those credentials (and change the password to something secure ASAP).

- 350
- 1
- 5
-
12
-
1After Homebrew installation it asks for the password for any user... – Cheetaiean Jun 04 '20 at 20:23
I my self run in to the same problem, turned out I had Postgres already installed without Homebrew. After I deleted that install, the homebrew install worked and it didn't prompt me for a password anymore.

- 1,207
- 1
- 8
- 6
I ran into the same probelm and solved like this.
This could be due to the reason that you installed postgres
previously from other sources and then tried uninstalling. It did leave postgres
user account on your system. Go to user & accounts
from system preferences
. From there, remove the postgres
user account. Now restart and then try installing with brew. This should work.

- 9,678
- 3
- 51
- 50
I met this issue again and just used psql postgres
to solve this issue.
It displays like below:
➜ ~ psql postgres
psql (14.7 (Homebrew))
Type "help" for help.
postgres=#
but I can not use psql -U postgres
, it display like below:
➜ ~ psql -U postgres
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "postgres" does not exist

- 11
- 2
I've installed Postgres 14 using Homebrew. I tried using postgres
as the password while logging in for the first time and it worked.
hackyroot@Root-MacBook-Air ~ % psql -U postgres
Password for user postgres:
psql (14.8 (Homebrew), server 15.3)
WARNING: psql major version 14, server major version 15.
Some psql features might not work.
Type "help" for help.
postgres=#

- 321
- 3
- 12
With PostgreSQL 5 with Homebrew on MacOS Ventura 13.5.1:
user: my logged user password: postgress
How to find out:
On terminal:
psql postgres
and then:
postgres=# \du
Your username should be listed. Let's validate it. Type "\q" to
postgres=# \q
And then:
psql -U usernameListedAbove postgres

- 1,102
- 1
- 13
- 17