How to access the discourse database?

Hi all,

This is probably a stupid question but how can I access the database?
Is there something equivalent to phpadmin (or another GUI) that I can use to view and edit the database of discourse? If not, then what is the best way to access/view/edit it?

1 Like

Install the Data Explorer Plugin and have at it.

If you want to do postgres command line stuff, you’ll need to enter the container to do that using the Docker enter command.


Thank you!

I just installed the plugin, but I am getting this error message: “The data explorer is only available to admins.”
This is weird because I am an admin.
Even if I use this to create a new admin account, I keep seeing this message.

My admin accounts are also visible in /admin/users/list/admins.

What do I do wrong?

Edit: omg nvm, I had to enable it first in the settings after installing it


Hi, Docker enter, but what’s next?

I tried psql but got psql: FATAL: role "root" does not exist

postgres runs under the postgres user, per:

You want to sudo postgres psql discourse to hit the right user and database…


I see , thank you! @sam

In case anyone else is confused the actual command you need to run inside the container is:

sudo -u postgres psql discourse

i.e. ‘Run psql discourse as the postgres user.’


sudo -u postgres psql discourse

This lists the 156 tables:

discourse=# \dt

But basic queries return nothing:

discourse=# select * from users limit 1

This is a working site, so I’m sure there is data. What am I doing wrong?

1 Like