pg_dump: error: connection to database “gitlabhq_production” failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/opt/gitlab/postgresql/.s.PGSQL.5432”?
So I restart gitlab with sudo gitlab-ctl start and I try again. This time I get the error
pg_dump: error: connection to database “gitlabhq_production” failed: FATAL: Peer authentication failed for user “gitlab”
I do some Googling and think that maybe I’m trying to access the database with the wrong user. So I try SRC_PGUSER=gitlab-psql and try again.
pg_dump: error: connection to database “gitlabhq_production” failed: FATAL: Peer authentication failed for user “gitlab-psql”
Any idea what I’m doing wrong? What do I need to do to dump the database?
I tried installing PostgreSQL separately from GitLab and I ran into pretty much the same problem. Still can’t access the database. But now I think I know where my problem is. From /var/log/gitlab/postgresql/current:
2024-02-07_11:28:01.85776 LOG: no match in usermap "gitlab" for user "gitlab-psql" authenticated as "ec2-user"
2024-02-07_11:28:01.85782 FATAL: Peer authentication failed for user "gitlab-psql"
And if I sudo it, then I get the same error but authenticated as “root.”
So I tried sudo su gitlab-psql then tried this command:
could not change directory to "/home/ec2-user": Permission denied
pg_dump: error: could not open output file "gitlabhq_production.sql": Permission denied
So I think I need to set up the usermap “gitlab” to let user “gitlab-psql” authenticate as “ec2-user.” Any idea how I could go about that?
Edit: I was able to open psql and I ran CREATE USER "ec2-user" SUPERUSER; and I’m going to see where I can get with that…