Skip Navigation
Lemmy Support @lemmy.ml maxmoon @lemmy.ml

How to connect to the database if Lemmy is in a docker container?

I've installed Lemmy via ansible, but I figured out that there are problems with emails and after I've created a user, no verification email came, no login is possible and now I have a ghost account I want to delete.

Because I couldn't find an UI element to purge users in the admin panel, I want to do it over postgresql, but I have no idea how to connect to the Lemmy database over a docker container, only thing I've found is to backup/restore the whole database:

docker-compose exec postgres pg_dumpall -c -U lemmy | gzip > lemmy_dump_date +%Y-%m-%d""%H%M_%S.sql.gz

Thank you for your help.

18

You're viewing a single thread.

18 comments
  • if you already have the container up you can run "docker exec -it postgres bash". this will open the shell of the postgres container

    in that i think you can run postgres commands with "psql"

    • docker exec -it postgres bash

      After executing this command and executing psql, I got this error:

      psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist

      • psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist

        try

        psql -U postgres

        • psql -U postgres

          No luck with this comman :(

          psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "postgres" does not exist

          But is it the right docker container? The name of the container I try to connect is lemmymydomaintld_postgres_1

          Seems pretty hard to delete a user this way. Do you know an easier way by any chance?

          • yea im p sure cuz otherwise psql wont work

            try

            psql -U lemmy

            i havent used lemmy, just know a bit of docker

            • I found a solution here

              A warning to people who have the same problem:

              On the website there is a command, which will purge all unverified account. If your admin account wasn't verified, it will be purged, too.

              Thanks a lot for your help :)

You've viewed 18 comments.