Hi guys, I just started installing postgres on my ubuntu VM. I referred some docs, and followed this one: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
Its pretty much explained in this page. But just explaining here the important things.
You can install postgres by ubuntu’s own apt packaging system. Update local apt repository.
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib
Postgres uses role based access for the unix users. After the installation a default role called ‘postgres’ will be created. You can login to postgres account and start using or creating new roles with Postgres.
Sign in as postgres user
$ sudo -i -u postgres
Access the postgres console by
$ psql
But i cannot enter into the console and I got the following error:
postgres@8930a29k5d05:/home/rails/my_project$ psql
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"?
What could be the reason for this error?
So just gone through Postgres doc (http://www.postgresql.org/docs/9.3/static/server-start.html). You can see the same error under the section 17.3.2. Client Connection Problems. But the solution is not mentioned.
Original Reason: PostgreSQL Server was not running after the installation.
I tried rebooting the system and via init script the server should run automatically. But the server is not running again. I understood that something prevents postgres from running the server. What is it?
Just check your postgres server is running or not
$ sudo -aux | grep post
postgres@8930a29k5d05:/home/rails/my_project$ ps -aux | grep postgres
root 136 0.0 0.2 47124 3056 ? S 06:10 0:00 sudo -u postgres -s
postgres 137 0.0 0.3 18164 3220 ? S 06:10 0:00 /bin/bash
postgres 140 0.0 0.2 15572 2192 ? R+ 06:10 0:00 ps -aux
postgres 141 0.0 0.0 4892 336 ? R+ 06:10 0:00 grep post
The server is not running.
Run the server manually by
root@8930a29k5d05:/home/rails/my_project# /etc/init.d/postgresql start
* Starting PostgreSQL 9.3 database server
[ OK ]
root@8930a29k5d05:/home/rails/my_project# ps aux | grep postgres
postgres 158 0.1 2.0 244928 20752 ? S 06:28 0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
postgres 160 0.0 0.3 244928 3272 ? Ss 06:28 0:00 postgres: checkpointer process
postgres 161 0.0 0.4 244928 4176 ? Ss 06:28 0:00 postgres: writer process
postgres 162 0.0 0.3 244928 3272 ? Ss 06:28 0:00 postgres: wal writer process
postgres 163 0.0 0.5 245652 6000 ? Ss 06:28 0:00 postgres: autovacuum launcher process
postgres 164 0.0 0.3 100604 3336 ? Ss 06:28 0:00 postgres: stats collector process
root 178 0.0 0.0 8868 884 ? S+ 06:28 0:00 grep --color=auto post
root@8930a29k5d05:/home/rails/my_project#
Now the server starts running. If still not works, then try to reconfigure your locales as mentioned here
$ dpkg-reconfigure locales
It is strange that, after installing such a popular database software, it doesn’t provide any information regarding the failure of its own server. It should give the developers some clue so that they can save their precious time.
The reason of this failure, what I concluded is
1. After installation we have to run the server manually
OR
2. I tried resetting the locales (So if no locales set in the machine may prevented the postgres from starting automatically?)