lemmy-docs icon indicating copy to clipboard operation
lemmy-docs copied to clipboard

Contributor local development postgreSQL missing a step

Open willhansen opened this issue 2 years ago • 1 comments

For this section

Selection_206 https://join-lemmy.org/docs/contributors/02-local-development.html#setup-postgresql-database

Running scripts/db-init.sh led to the error

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres".

I had to modify my /etc/postgresql/14/main/pg_hba.conf to get around this. I'm not sure what the "correct" fix is.

willhansen avatar Jul 04 '23 00:07 willhansen

Adding some notes here on adjacent topics. On my Ubuntu 22.04.2 development system, I wanted to have postgresql 15 instead of the 14 that comes with Ubuntu. I followed install from: https://www.postgresql.org/download/linux/ubuntu/

psql command could be located fine, but pg_ctl and initdb are not set to path by default install following the official install steps. So I edited the scripts to use the full path to those commands.

# If cluster exists, stop the server and delete the cluster
if [ -d $PGDATA ]
then
  # Prevent `stop` from failing if server already stopped
  /usr/lib/postgresql/15/bin/pg_ctl restart > /dev/null
  /usr/lib/postgresql/15/bin/pg_ctl stop
  rm -rf $PGDATA
fi

# Create cluster
# command is not on path in following pg 15 install on Ubuntu 22.04.2
#    /usr/lib/postgresql/15/bin/initdb
/usr/lib/postgresql/15/bin/initdb --username=postgres --auth=trust --no-instructions

# Start server that only listens to socket in current directory\
#  command not found on Ubuntu 22.04.2 install too
#  /usr/lib/postgresql/15/bin/pg_ctl
/usr/lib/postgresql/15/bin/pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PWD" > /dev/null

RocketDerp avatar Jul 18 '23 02:07 RocketDerp