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.
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
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
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
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
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
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
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.
3. Open the downloaded zip file and click Extract All.
4. Choose the destination folder and click Extract.
5. The SQL Workbench requires JRE to run. Run the download_jre.cmd script.
The script automatically opens the command prompt.
6. The batch script downloads the latest available Java JRE. Press y to start the download.
The download automatically starts.
7. When the download completes, the installation script asks if the zip file for installing Java should be removed.
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.
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.
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).
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
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
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
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
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
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
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.