PostgreSQL Details

AI-generated summary

The discussion revolves around accessing PostgreSQL details in a Discourse installation. Marcell_Csendes initially sought the database username and password for use in a desktop app like DBeaver. cocococosti explained that a standard Docker setup allows access to the PostgreSQL database as the postgres user without a password, using commands like su postgres and psql. Falco clarified that the default setup trusts local connections, so no password is needed, but to access it externally, the port must be exposed and a new user with read access created. Marcell_Csendes confirmed that creating a new user resolved the issue. merefield suggested using the Data Explorer plugin as an alternative, though Marcell_Csendes preferred DBeaver due to managing multiple databases.

Hey,

I was wondering how do you access Postgresql details? Like where would I see the pw and the user for instance? I know the rest of course.

Take a look at this Topic, it gives you the series of commands you need about half way down:

I didn’t expect it to be this of a big deal to just get password and username lol

Assuming you have a standard Discourse docker installation, you can connect to the postgres database with the postgres user. No password needed:

cd /var/discourse
./launcher enter app
su postgres
psql
\c discourse

If you want to list all users you can run \du

I wished to access from a desktop app like DBeaver, which is why I was curious. Obviously I don’t want to force change the user password as it would break the community.

Never used DBeaver before but I think it should work with an empty password Connection without password is not supported · Issue #6269 · dbeaver/dbeaver · GitHub

Hmm, that might work but I also received “FATAL: password authentication failed for user “discourse””

Try with postgres as the username.

                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 discourse |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

It must be discourse, but then it should be something with the authentication.

We configure the database to trust and allow connections from the same IP without a password, so there isn’t a password for you to find.

If you have a standard Discourse install, you will need to:

  • change the app.yml configuration to expose the 5432 port to the external world

  • create a new username/password pair that has read access to the tables you want

Yeah, the port expose was clear in the first place.

Uhm, I have no idea why I didn’t think of the new user lol, that worked. Thx

Consider the data explorer plugin, much less hassle!

I see your idea, the reason I went with DBeaver, is because I deal with more databases beside of Discourse’s, so that’s why decided to do this way.

Sure that makes complete sense. I’d have done the same had I not become more familiar with discourse’s ecosystem.