159

I need the psql command line tools, but I don't need the actual Postgres RDBMS. This is to work with a package which supports a psql interface.

Is it possible to install just psql?

(Ubuntu 16.04)

3 Answers 3

269

Oh, yes:

$ sudo apt-get install -y postgresql-client
$ psql --version  
psql (PostgreSQL) 9.5.12
1
9

If you don't want to install anything, just download the package https://www.enterprisedb.com/download-postgresql-binaries

Then run unpack and run ./bin/psql No installation.

The package also contains postgres server which you can run at local without installation also. For more, ref https://www.golery.com/pencil/vU

8

psql is part of the client. To install the client:

Debian/Ubuntu:

$ sudo apt install postgresql-client

RedHat family:

$ sudo yum install -y postgresql

or with dnf package manager (RHEL 8+, Fedora):

$ sudo dnf install -y postgresql

If you need a specific postgres release, the names of the packages would be like this:

$ sudo apt install postgresql-client-15
$ sudo yum install postgresql15

If your OS distribution doesn’t have PostgreSQL in the repository out-of-the-box or you need the latest or a specific Postgres version, you may need to configure the repository first. The official PostgreSQL manual (https://www.postgresql.org/download/linux/) is quite helpful. For Ubuntu they propose this:

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

For RedHat family they have a form: you fill in Postgres version, OS, Architecture, and you get the script to install postgres server. As we are interested in the client, we only need the command to install the repository RPM. For instance,

for RHEL 7:

$ sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

For RHEL 8:

$ sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

You can also check out the page RisingWave DB project has on their web site. They are using psql as the client app for their DB, and so they have info on installing Postgres client on different popular platforms (macOS and Windows included). Hope they’ll keep the page updated.

2
  • Hi and welcome. Generally it's better to directly include information in answers, rather than just linking to somewhere else where that info is. Commented Jun 21, 2023 at 1:06
  • 2
    @SteveBennett Thanks! I have updated my answer to include the referenced info and more. Is it better now? Commented Jun 22, 2023 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .