1
votes

Through some mishap I seem to have 2 separate Postgres servers on my local Ubuntu machine. PGAdmin connects to one (localhost:5432), which can also be reached with the terminal through: sudo -u postgres psql postgres -W -h 127.0.0.1 -p 5432

The other "default" server can be reached through the terminal with just sudo -u postgres psql postgres

For other info, locate bin/psql returns:

/usr/bin/psql

/usr/lib/postgresql/9.5/bin/psql

I suspect the latter of those directories is the Postgres 9.5 instance I really want to use, and the one I want to associate with without needing to specify -h 127.0.0.1 -p 5432. The other can be removed completely. How do I resolve this?

1

1 Answers

1
votes

You can use the package manager to remove it.

From terminal, you can list the installed versions of PostgreSQL executing:

$ apt list --installed | grep postgresql

The ones with the format postgresql-X (where "X" is the version) is those to remove. You should be able to do it with the apt purge command.

For example, to remove the version 9.6, you have to execute:

$ sudo apt purge postgresql-9.6

/usr/bin/psql should be a symbolic link to the most recent version installed (/usr/lib/postgresql/9.6/bin/psql).