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?

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.

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

Dies listet die 156 Tabellen auf:

discourse=# \dt

Aber einfache Abfragen geben nichts zurück:

discourse=# select * from users limit 1
discourse-#

Dies ist eine funktionierende Seite, also bin ich mir sicher, dass es Daten gibt. Was mache ich falsch?

Das gleiche Problem wie bei Mark oben

  1. Verwenden Sie, wenn möglich, das Plugin data-explorer – es bietet zusätzliche Sicherheitsprüfungen und einen Schema-Explorer.
  2. Sie müssen Befehle in der psql-Konsole mit einem ; Semikolon abschließen.

Könntest du diesen Vorgang bitte erklären? Ich bin ein Neuling im Bereich Container und würde gerne anfangen, mit meiner PostgreSQL-Datenbank zu experimentieren, anstatt den Container wie eine große Blackbox zu behandeln :slight_smile:

Hier ist es, speziell für dich, @Divert:

Ausgehend davon, dass du dich im OOTB-Einzelcontainer-Modus im standardmäßig unterstützten Setup befindest:

cd /var/discourse
./launcher enter app
su discourse
psql discourse

Wenn alles ordnungsgemäß läuft, befindest du dich nun in der Datenbank als Benutzer „discourse

@neounix Vielen Dank für diese Antwort! Du hast wirklich alles gegeben, und ich weiß das sehr zu schätzen. :smile:

Gibt es eine Möglichkeit, sich mit einer Discourse-Datenbank (selbst gehostete Docker-Installation) über einen SQL-Client (wie PSequel für Mac) zu verbinden?

Abgesehen von der Verwendung von Docker, womit ich nicht vertraut bin (und die DB nicht beschädigen möchte), gibt es SQL-Befehle, die ich über das Data Explorer-Plugin ausführen könnte, um die Namen der Datenbanken anzuzeigen, auf die ich in Discourse zugreifen kann?