Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql won't work on ubuntu 16.04

I have installed postgresql 9.5.13, but it seems not to work. I get continiosly this message:

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 "/var/run/postgresql/.s.PGSQL.5432"?

when i try to create user. I have seen that this is common problem, but i can't find solution for this.

like image 380
Bozidar Milivojevic Avatar asked Feb 06 '23 20:02

Bozidar Milivojevic


2 Answers

See if the service is running

systemctl status postgresql

If PostgreSQL is running, you'll see output that includes the text Active: active (exited).

If you see Active: inactive (dead), start the PostgreSQL service using the following command:

systemctl start postgresql

PostgreSQL also needs to be enabled to start on reboot. Do that with this command:

systemctl enable postgresql

Run

pg_lsclusters

Ver Cluster Port Status Owner    Data directory               Log file
9.5 main 5433 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Status - online - fine
like image 179
Maryan Avatar answered Feb 09 '23 10:02

Maryan


Start the server using the default database path by typing this :

sudo -i -u postgres

/usr/lib/postgresql/9.5/bin/pg_ctl -D /var/lib/postgresql/9.5/main/ -l logfile start

than try:

psql

Done !

like image 36
Mounirsky Avatar answered Feb 09 '23 11:02

Mounirsky