I tried to install postgresql on Linux Manjaro and create db and user.
I have executed next commands:
$ sudo pacman -S postgresql postgis
$ sudo -u postgres -i
Than
$ initdb -D '/var/lib/postgres/data'
returns 'access denied' error.
I was trying to create connection via pgAdmin4. Than I got next error:
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I found a lot of similar issues. So tried some solves like changing the path of db location or reinstall postgresql.
My aim is to run pg in Rails. But now I have
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"
when I am trying to execute
$ rails db:create
Seems, I do not understand the whole way of pg configuring. Thank you!
UPDATED: Next commands solved the problem:
sudo pacman -R postgresql
sudo pacman -S postgresql postgis
sudo su - postgres -c "initdb -E UTF8 -D '/var/lib/postgres/data'"
systemctl start postgresql
systemctl status postgresql
sudo su - postgres
createuser user1
createdb -O user1 db1
psql db1 -U user1
Next commands solved the problem:
sudo pacman -R postgresql
sudo pacman -S postgresql postgis
sudo su - postgres -c "initdb -E UTF8 -D '/var/lib/postgres/data'"
systemctl start postgresql
systemctl status postgresql
sudo su - postgres
createuser user1
createdb -O user1 db1
psql db1 -U user1