Skip to content

Instantly share code, notes, and snippets.

@radiaku
Last active May 18, 2025 21:48
Show Gist options
  • Save radiaku/3a210137f17aadda7ba59b40f59b4387 to your computer and use it in GitHub Desktop.
Save radiaku/3a210137f17aadda7ba59b40f59b4387 to your computer and use it in GitHub Desktop.
Install postgres v15 on arch linux
yay -S postgresql15

run this:

. /opt/postgresql15/bin/pgenv.sh

init database first:

sudo -u postgres /opt/postgresql15/bin/initdb -k -D /var/lib/postgres/data15

fix permission

sudo mkdir -p /run/postgresql
sudo chown postgres:postgres /run/postgresql
sudo chmod 755 /run/postgresql

dont forget log file:

sudo touch /var/lib/postgres/data15/logfile
sudo chown postgres:postgres /var/lib/postgres/data15/logfile

check and login:

sudo -u postgres /opt/postgresql15/bin/psql
or
sudo -u postgres psql

Optional:

if you want it run on background:

[Unit]
Description=PostgreSQL 15 database server
After=network.target

[Service]
Type=forking
User=postgres
RuntimeDirectory=postgresql
RuntimeDirectoryMode=0755
Environment=PGDATA=/var/lib/postgres/data15
ExecStart=/opt/postgresql15/bin/pg_ctl start -D /var/lib/postgres/data15 -s -l /var/lib/postgres/data15/logfile
ExecStop=/opt/postgresql15/bin/pg_ctl stop -D /var/lib/postgres/data15 -s -m fast
ExecReload=/opt/postgresql15/bin/pg_ctl reload -D /var/lib/postgres/data15 -s
TimeoutSec=300

[Install]
WantedBy=multi-user.target

restart and reload daemon and enable service:

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable postgresql15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment