Ubuntu get PostGreSQL running

I have installed PostGreSQL 8.3 on an Ubuntu machine and I want to configure a pssw for it, however when I run this command:

sudu su postgres -c psql template1

I get the following error:

"psql: 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"?"

Can anybody tell me how I can check if the db server is running locally (only accepting connections on localhost)?

How I can start the psql server?

I'm a Linux newbie, btw


Solution 1:

You can know the status of your Postgres server via the command

sudo /etc/init.d/postgresql-8.3 status

To start it you can issue the command

sudo /etc/init.d/postgresql-8.3 start

and to stop you can issue the command

sudo /etc/init.d/postgresql-8.3 stop

Solution 2:

First, check whether the server is running or not. The command for checking this is:

service postgresql status

it will check the status of server if you found

postgresql.service - PostgreSQL RDBMS

Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor pres

Active: inactive (dead)

Then you have to restart the server by the given command and mostly this problem is coming in 9.6.1 version of PostgreSQL.

service postgresql restart

Then the PostgreSQL server will run correctly in Ubuntu terminal