How to Install SQL Workbench for PostgreSQL

Introduction

SQL Workbench/J is a Java-based program that supports SQL queries for various database management systems (DBMS), including PostgreSQL. The lightweight and portable program works on different operating systems and simplifies database management by focusing on query execution.

This tutorial shows how to install and set up SQL Workbench for PostgreSQL on Ubuntu, Windows, and Mac.

Guide on setting up SQL Workbench for PostgreSQL on Linux, Windows, and macOS.

Prerequisites

  • Access to a terminal/command prompt.
  • A user account with sudo or administrator privileges.
  • PostgreSQL installed with a configured user.

Note: To install PostgreSQL, follow one of our guides:

Install SQL Workbench for Postgres on Ubuntu

To install SQL Workbench/J on Ubuntu, open the terminal and follow the steps below:

1. Download the package with the following wget command:

wget https://www.sql-workbench.eu/Workbench-Build131-with-optional-libs.zip
wget sql workbench download terminal output

The system proceeds to download the zipped package from the official page.

2. Unzip the file:

unzip Workbench-Build131-with-optional-libs.zip -d ~/Desktop/Workbench
unzip sql workbench 131 terminal output

The output shows the extraction process. The unzipped contents are saved in ~/Desktop/Workbench.

Note: If unzip is unavailable, install it with sudo apt install unzip.

3. Move to the directory where the contents were extracted with the cd command and list the contents:

cd ~/Desktop/Workbench && ls -l
sql workbench directory contents scripts terminal output

The directory contains various setup files and scripts. The following steps will run the download_jre.sh and sqlworkbench.sh scripts to complete the setup.

4. Run the shell script for downloading JRE:

sudo sh download_jre.sh
sudo sh download_jre.sh terminal output

The system runs the script, downloading and installing the latest Java version.

5. Download the latest Postgres JDBC driver and save the jar file in a ~/Desktop/PostgresJDBC directory:

wget -P ~/Desktop/PostgresJDBC https://jdbc.postgresql.org/download/postgresql-42.7.4.jar
wget PostgresJDBC driver terminal output

The output from the terminal confirms that the jar file was successfully downloaded and saved.

6. Enter the following command to start the SQL Workbench shell:

sudo bash ~/Desktop/Workbench/sqlworkbench.sh
SQL Workbench connection profile prompt

The command launches the SQL Workbench connection profile interface.

7. Fill in the database connection details. Provide a name for the connection and select the PostgreSQL driver. Enter the connection details (the URL for the server, username, and password).

The URL is in the following format:

jdbc:postgresql://[server_IP]:[port_number]/

To see the connection details in PostgreSQL, use the /conn meta-command.

Install SQL Workbench for Postgres on Windows

To install SQL Workbench for Postgres on Windows, do the following:

1. Navigate to the official SQL Workbench/J downloads page using a web browser.

2. Download the preferred package from the list. We recommend the comprehensive bundle with all optional libraries.

Download links SQL Workbench downloads page

3. Open the downloaded zip file and click Extract All.

Extract all workbench build zip file

4. Choose the destination folder and click Extract.

Extract SQL Workbench destination folder

5. The SQL Workbench requires JRE to run. Run the download_jre.cmd script.

SQL Workbench folder download_jre.cmd

The script automatically opens the command prompt.

6. The batch script downloads the latest available Java JRE. Press y to start the download.

Batchfile Java 17 JRE 64-bit CMD output

The download automatically starts.

7. When the download completes, the installation script asks if the zip file for installing Java should be removed.

JRE delete zip archive CMD output

Press y to clean up and close the script.

8. Download the PostgreSQL JDBC plugin manually. Navigate to the PostgreSQL JDBC driver download page and download the latest version.

Postgres JDBC download latest

Place the driver in a secure location. No installation is required, but SQL Workbench/J will not work without it.

9. Start the SQL Workbench. Navigate to the folder with the executable files and run the SQLWorkbench or SQLWorkbench64 application, depending on your system build.

SQLWorkbench or SQLWorkbench64 application

10. Create a connection profile. Give the profile a name and choose the PostgreSQL driver from the dropdown (provide the path if prompted). Fill in the connection details (server URL, username, and password).

SQL Workbench select connection profile windows

The URL is in the following format:

jdbc:postgresql://[server_IP]:[port_number]/

Connection details are visible in Postgres with the /conn meta-command.

Install SQL Workbench for Postgres on Mac

To install SQL Workbench for Postgres on Mac, do the following:

1. Open the terminal and use the following curl command to download SQL Workbench:

curl -O https://www.sql-workbench.eu/Workbench-Build131-with-optional-libs.zip
curl SQL workbench download Mac output

The command downloads the package from the official SQL Workbench website.

2. Unzip the downloaded package to a specific directory. For example:

unzip Workbench-Build131-with-optional-libs.zip -d ~/Desktop/Workbench
unzip workbench build 131 Mac terminal output

The package is in ~/Desktop/Workbench.

Note: If the unzip command is unavailable, install it with: brew install unzip.

3. Navigate to the directory and list its contents:

cd ~/Desktop/Workbench && ls -l
SQL workbench package contents and scripts Mac output

The directory contains files that will be used in the following steps to complete the installation and start the program (download_jre.sh and sqlworkbench.jar).

4. Run the following shell script to download the latest available JRE version:

sudo ./download_jre.sh
sudo download_jre.sh script mac output

SQL Workbench requires JRE to work.

5. Create a directory to store the PostgresJDBC driver:

mkdir -p ~/Desktop/PostgresJDBC

The driver is required to connect the SQL Workbench to the PostgreSQL server.

6. Download the latest driver with:

curl -o ~/Desktop/PostgresJDBC/postgresql-42.7.4.jar https://jdbc.postgresql.org/download/postgresql-42.7.4.jar
PostgresJDBC driver download Mac output

The command downloads the driver and saves it in the directory created in the previous step.

7. Start the SQL Workbench:

java -jar ~/Desktop/Workbench/sqlworkbench.jar
Select connection profile Mac

The command opens the program to create a connection profile.

8. Create the connection profile. Give the connection a name and provide the database connection details. Select the PostgreSQL driver (browse for the file if prompted), and fill out the database connection details (URL, username, and password).

Use the following URL format:

jdbc:postgresql://[server_IP]:[port_number]/

The /conn meta-command in PostgreSQL shows the connection details required for the URL.

Conclusion

This guide showed how to install and set up SQL Workbench/J for PostgreSQL. The process requires installing SQL Workbench and adding the appropriate PostgreSQL driver to connect.

Next, learn more about PostgreSQL data types or create a database in Postgres.

Was this article helpful?
YesNo
Milica Dancuk
Milica Dancuk is a technical writer at phoenixNAP with a passion for programming. With a background in Electrical Engineering and Computing, coupled with her teaching experience, she excels at simplifying complex technical concepts in her writing.
Next you should read
How to Export a PostgreSQL Table to CSV
March 17, 2020

Learn how to export a PostgreSQL table to a .csv file. This feature is especially helpful when transferring...
Read more
How to Deploy PostgreSQL on Docker Container
October 3, 2024

PostgreSQL is the third most popular Docker image used for deploying containers. Run PostgreSQL on Docker by...
Read more
How to Install PostgreSQL on Ubuntu 18.04
March 14, 2024

PostgreSQL is an open-source, relational database management system. There are two simple ways of installing...
Read more
PostgreSQL Vs MySQL: A Detailed Comparison
March 30, 2023

Explore the differences between the two most widely used database management systems. PostgreSQL and MySQL...
Read more