There seems to be lots of questions likes this on stackoverflow, but none of them seemed to help me. I am runing Ubuntu on my windows linux subsystem and trying to install and use postgresql.
I installed in like this:
sudo apt-get install postgresql postgresql-contrib postgresql-client
pgadmin3
which worked fine:
near the bottom the install log says:
Creating new cluster 9.5/main ...
config /etc/postgresql/9.5/main
data /var/lib/postgresql/9.5/main
locale C
socket /var/run/postgresql
port 5433
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
invoke-rc.d: could not determine current runlevel
Setting up postgresql (9.5+173) ...
Setting up postgresql-client (9.5+173) ...
Setting up postgresql-contrib-9.5 (9.5.8-0ubuntu0.16.04.1) ...
Setting up postgresql-contrib (9.5+173) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
So the port is 5433. This is also the port listed in the postgresql.conf file.
When I type psql I get:
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.5433"?
When I do:
ps -df | grep postgres
I get a different port though (5432) and this is returned:
spotter 12 2 0 18:55 tty1 00:00:00 /usr/lib/postgresql/9.5/bin/psql -h 199.92.170.64 -d rtu_prod -Usv-read -p 5432
spotter 1835 2 0 20:21 tty1 00:00:00 grep --color=auto -a postgres
spotter 6134 2 0 20:51 tty1 00:00:00 grep --color=auto -a postgres
spotter 9348 2 0 22:06 tty1 00:00:00 grep --color=auto postgres
I think this might mean I have two versions of postgresql installed but I'm not sure.
Based on other posts I should enter /usr/lib/postgresql/9.5/bin/psql -h 199.92.170.64 -d rtu_prod -Usv-read -p 5432 to start it, but this asks for a password I have never heard of Password for user sv-read:
psql -h /tmp?psql -h localhost?psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?Interesting its a different socket. The second one returned:psql: FATAL: could not load pg_hba.confI may have two versions of posgresql installed then...psql -h 199.xx.xxx.64 -d rtk_prcd -U sv-read -p 5432and I got in fine, so I don't know whats going on.