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)
Oh, yes:
$ sudo apt-get install -y postgresql-client
$ psql --version
psql (PostgreSQL) 9.5.12
yum -y install postgresql
- unix.stackexchange.com/a/249495/191475 . Oracle database in Docker is the case (I needed to access PG from Oracle.)
Commented
Apr 11, 2022 at 21:49
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
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.