I installed postgresql on archlinux using this command:
sudo pacman -S postgresql
And it installed OK. But when I want to create a new user, like this:
sudo -iu postgres
[postgres@amirashabani ~]$ createuser amirashabani
I receive this 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 "/run/postgresql/.s.PGSQL.5432"?
How can I fix this?
The problem was that I forgot to start
and enable
the postgresql service, which was mentioned in the ArchWiki:
After doing this:
systemctl start postgresql.service
systemctl enable postgresql.service
Everything worked fine.