Skip to content

Instantly share code, notes, and snippets.

@blackode
Forked from tacionery/postgres_guide
Last active May 19, 2023 07:46
Show Gist options
  • Save blackode/61417cdb8809596345e7c6f70c95d236 to your computer and use it in GitHub Desktop.
Save blackode/61417cdb8809596345e7c6f70c95d236 to your computer and use it in GitHub Desktop.
install postgresql on antergos

uninstall postgresql if necessary

sudo pacman -R postgresql postgresql-libs

remove postgres files

sudo rm -rfv /var/lib/postgres

proceed with the installation

sudo pacman -S postgresql postgresql-libs

setup password for postgres

sudo passwd postgres

create this file

sudo vim /usr/lib/systemd/system/rc-local.service

paste this

[Unit]
Description=/etc/rc.local compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

now create this file

sudo vim /etc/rc.local

and paste this

#!/bin/sh -e
#
# rc.local
exit 0

make the /etc/rc.local executable

sudo chmod +x /etc/rc.local

enable the rc.local.service

sudo systemctl enable rc-local.service

now log in with postgres user

sudo su - postgres

Database Initation and Service

init the database

 initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
 exit

now start postgresql service

sudo systemctl start postgresql.service

Running process

You can run that with the follwing command

psql -U postgres

This won't ask for the password but you can force that wit -W option like

psql -U postgres -W 

However, you can also pass the -d option to connect directly with database mentioned like psql -U username -d dbname.

๐Ÿ’ Hope this helps you ๐Ÿ’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment