I was trying to get the username and password in order to connect to pgAdmin. I tried every method above and couldn't find the values for username
and password
for my database in development in rails 7.
It turns out pgAdmin didn't actually need the username and password for the individual app's database; instead, it will authenticate to the postgres server and hence have access to all databases on the server.
This may solve the problem for people needing the username
and password
for similar reasons to me.
But this doesn't explain why I was unable to get the username
and password
for my specific (rails 7) app. The best I can guess is it's because Rails 7 defaults to using default credentials to connect to the local database.
In my case (PostgreSQL) uses the username "postgres" by default with no password or a blank password.
So if you check in config/database.yml
and the dev environment is referring to default
, and those defaults don't list anything for username
and password
explicitly, it might be using your database's default creds. I couldn't find any way to confirm this though, it's merely my suspicion based on what I see in rails 7's database.yml
, the fact ENV
gives nothing related to the db, and that all the above methods gave no results.