Postgres 4 Planners : Install psql without PostgreSQL

This is a slightly more advanced topic looking at something called psql which is a set of bundled command line tools required if you need to undertake some basic database administration tasks like importing shape files and importing csv files. If you are new to Postgresql I recommend you work through the other topics first.

It comes with a command line shell which can provide a connection and command line interface to connect to databases and run SQL. Once installed you open that shell by typing psql in the windows search bar you will see something like this.

On installation of Postgres a number of vital tools come with the installation. These are simple executables that users can trigger to perform important tasks. Things like backing up databases and importing data. Even if you don’t have the full installed database you will still need this tooling if you are wanting to interact with a remote postgres server.

To install psql without the rest of the PostgreSQL package, you can use your operating system’s package manager. Here are the steps to install psql on some common operating systems: 

  • macOS
  • Debian/Ubuntu
  • Red Hat/CentOS
  • Fedora
  • Windows

Additional to the shell you can call individual functions of the program from the DOS command line – this is used for things like my CSV import routine.

Windows

For windows users use the package manager and select the appropriate option at install see LINK to interactive installer by EDB.

This is the usual way of installing PostgreSQL on Windows. But to install the client only, select Command Line Tools and uncheck other options when selecting components during installation.

Note typically it will be installed in a directory with the following path (replace 16 with your relevant postgres version)

c:\\program files\postgresql\16\bin

Background

Sometimes you need a PostgreSQL client, not the PostgreSQL server. The PostgreSQL official installers and packages come with all the components needed to run a PostgreSQL server, but some of these components are often not needed.

psql, which is included in the PostgreSQL package, is a command-line interface for interacting with PostgreSQL databases.  psql is an essential tool for you to connect to postgres, issue SQL queries, and manage database objects.