October 29, 2018 By Phil Alger 4 min read

Install only the necessary tools for a lean, mean PostgreSQL client machine

Why install all of PostgreSQL when your database server is up in the cloud, managed as an IBM Cloud Database for PostgreSQL?

Most instructions for installing the PostgreSQL tools assume you want the database installed too. It’s a reasonable assumption if you’re dealing with users who don’t have access to PostgreSQL in the cloud or on a remote server.

In this PostgreSQL Tip, we’ll look at how you can install just psql on Windows, Linux, and macOS, allowing you to quickly get up and running and connected to your IBM Cloud Databases (ICD) for PostgreSQL service. We’ll cover the following:

  • macOS with Homebrew

  • Ubuntu 16.04 and 18.04

  • Red Hat Enterprise Linux 7 (and others)

  • Fedora 27 and 28

  • Windows 10

Let’s dive in.

macOS with Homebrew

We recommend Homebrew as a package manager for macOS. With Homebrew in place, you’ll be able to install numerous applications, usually with the programs available in /usr/local/bin. Homebrew’s package for the PostgreSQL client tools is the libpq package. Brew makes it easy to install:

brew install libpq

There’s a small catch though—libpq won’t install itself in the /usr/local/bin directory. To make that happen, you need to run:

brew link --force libpq

This will symlink all the tools (not just libpq) into the /usr/local/bin directory. You’re now ready to run psql and start connecting.

Ubuntu 16.04 and 18.04

Linux systems (unlike macOS) have a package manager built in. For Ubuntu (and Debian-based distributions) thats’s the apt command. The PostgreSQL client is distributed in the appositely named postgresql-client, so all you need to do is run the following:

sudo apt-get install postgresql-client

This will install the PostgreSQL 10 client, which can easily connect to earlier versions of PostgreSQL.

Red Hat Enterprise Linux 7 (and others)

For Red Hat Enterprise Linux (RHEL), there’s a little more set up to do than with Ubuntu. For RHEL, the package manager is yum. First, you need to point yum at the PostgreSQL repository like this:

sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm

Yum goes to that URL and configures itself to use that package repository. With that done, you can add packages from it by name:

sudo yum install postgresql10

This installs just the client packages. If you are wondering where to find that repository URL, head to Linux Downloads (Red Hat Family). You’ll find a form which will let you select the PostgreSQL version, platform, and architecture, and it’ll give you the appropriate instructions for that Red Hat variant—that includes CentOS, Scientific Linux, and Oracle Enterprise Linux. It also includes Fedora.

Fedora 27 and 28

Fedora’s default repositories already have a PostgreSQL client available from them. So, for Fedora 27, 28, and later, install the PostgreSQL client from the terminal with:

sudo dnf install postgresql.x86_64

And that’s all you need to do!

Windows 10

On Windows 10, there’s a bit more work to be done. We currently recommend using the PostgreSQL installer from Enterprise DB. It’s a full installation package for PostgreSQL on Windows but you can set it to only install the command line tools like psql. Click on that link and select PostgreSQL 9.6 or 10 and Windows 10 as the platform. Once the executable file is downloaded, run it and you’ll see the following options:

Select only the Command Line Tools because we don’t need the server installed. After it installs, you’ll need to set up your Windows environment variables so that you can use the psql client in the command prompt.

Go to the Control Panel > System and Security > System and select Advanced system settings.

From there, you’ll see a box called System Properties. Select Environment Variables. A window will appear with the two sets of environment variables. In the top set (marked User variables for…), select the PATH entry and then click the Edit button. An edit window will appear. Click New and add the path to the psql client. Your path will depend on where PostgreSQL installed, but typically that would be:

C:\Program Files\PostgreSQL\10\bin

After that, click OK a couple of times to go back to the desktop. Start a new Command Prompt, and you should be able to run psql. With no server set and no server running locally, you’ll see the following, which means that it’s working:

Summing up

Now that we’ve covered getting set up with the psql client for PostgreSQL, you can start connecting to IBM Cloud Databases for PostgreSQL without having to install PostgreSQL itself on your local machine. In future PostgreSQL Tips, we’ll cover some of the basic features and functions of the database using your new psql client.

Learn more about IBM Cloud Databases for PostgreSQL

 

Was this article helpful?
YesNo

More from Cloud

The history of the central processing unit (CPU)

10 min read - The central processing unit (CPU) is the computer’s brain. It handles the assignment and processing of tasks, in addition to functions that make a computer run. There’s no way to overstate the importance of the CPU to computing. Virtually all computer systems contain, at the least, some type of basic CPU. Regardless of whether they’re used in personal computers (PCs), laptops, tablets, smartphones or even in supercomputers whose output is so strong it must be measured in floating-point operations per…

A clear path to value: Overcome challenges on your FinOps journey 

3 min read - In recent years, cloud adoption services have accelerated, with companies increasingly moving from traditional on-premises hosting to public cloud solutions. However, the rise of hybrid and multi-cloud patterns has led to challenges in optimizing value and controlling cloud expenditure, resulting in a shift from capital to operational expenses.   According to a Gartner report, cloud operational expenses are expected to surpass traditional IT spending, reflecting the ongoing transformation in expenditure patterns by 2025. FinOps is an evolving cloud financial management discipline…

IBM Power8 end of service: What are my options?

3 min read - IBM Power8® generation of IBM Power Systems was introduced ten years ago and it is now time to retire that generation. The end-of-service (EoS) support for the entire IBM Power8 server line is scheduled for this year, commencing in March 2024 and concluding in October 2024. EoS dates vary by model: 31 March 2024: maintenance expires for Power Systems S812LC, S822, S822L, 822LC, 824 and 824L. 31 May 2024: maintenance expires for Power Systems S812L, S814 and 822LC. 31 October…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters