'Default password for my user in postgresql

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?



Solution 1:[1]

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 | {}

Solution 2:[2]

There are two different "accounts" here:

  1. The OS X user that owns the PostgreSQL files and processes. When you installed PostgreSQL, you used your own user account for that.

  2. 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).

Solution 3:[3]

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.

Solution 4:[4]

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.

Solution 5:[5]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Moles
Solution 2 Peter Headland
Solution 3 Colby
Solution 4 Stirner
Solution 5 Koushik Das