I am trying to install and use PostgreSQL in ubuntu 14.04. I followed these commands to reinstall postgresql.
sudo apt-get --purge remove postgresql\*
sudo rm -r /etc/postgresql/
sudo rm -r /etc/postgresql-common/
sudo rm -r /var/lib/postgresql/
sudo userdel -r postgres
sudo groupdel postgres
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo -i -u postgres
postgres@user:~$ psql
Here the error comes,
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"?
When I check sudo service postgresql status
, it returns
9.6/main (port 5432): down
Then I run the command sudo service postgresql start
, it returns
* Starting PostgreSQL 9.6 database server
Again,
user@user:~$ sudo service postgresql status
9.6/main (port 5432): down
I don't know why? Someone please help. Thanks in advance.
EDIT:
I have another doubt, In postgresql, Is it not possible to create database or user other than the name of my linux account? I can create it in postgresql CLI, But I could not use it in my Rails application. It is throwing the error.
PG::ConnectionBad: FATAL: Peer authentication failed for user "jayam"