Is it possible to login into the postgres database inside the docker image?


(Badr) #1

Hello,

I need to integrate a product on my discourse by adding some tables to the discourse db in postgres. Where can I find the username and password for the PostGres DB Discourse is using.

I also wanted to ask if I change the postgres password like its suggested here:

 ./launcher enter app
su - postgres
psql
ALTER ROLE postgres WITH PASSWORD 'your-new-password';

will that break discourse or will discourse work with that new password…


(Allen - Watchman Monitoring) #2

Any reason not to make yourself a new service account w different name & password?


(Badr) #3

Because in order to do that I need to log into Postgres and I don’t know the account information Discourse uses for that.


(Alan Tan) #4

If you’re following the standard Docker install and did not change the postgres template, try

./launcher enter app
su postgres -c "psql discourse"

(Badr) #5

THANKS!

This is exactly what I was looking for…


(Jeff Atwood) #6

Amplifying on this, some basic postgres commands once you have the postgres command line in the container:

list all databases
\l

select a database
\c dbname

list tables in the current database
\dt

list columns in the users table
\d+ users

number of rows in the users table
select count(*) from users;

display value of configuration variables
show shared_buffers;

exit from the postgres console
\q

If you know SQL I am sure you can take it from here :wink: note that all SQL must terminate with semicolon ;

Also, some queries to identify largest tables.