IntroductionSQL Workbench/J is not to be confused with MySQL Workbench. SQL Workbench is a tool designed to handle SQL queries no matter which fundamental Database Management System (DBMS) you use.This tutorial shows you how to install and set up SQL Workbench for PostgreSQL. It includes instructions for a Debian based system (Ubuntu 18.04) as well as Windows, macOS, and Linux GUI.
- Access to a terminal or command line
- A user account with sudo privileges
- Administrator privileges
Install SQL Workbench for PostgresSQL Workbench helps you manage different database systems without the need to master each of their proprietary tools in turn.Installing SQL Workbench is a straightforward process that can be completed in a few short steps.
Step 1: Download and Unzip SQL Workbench Distribution PackageUbuntu 18.04To download a generic package for all systems, enter the following command in your command line terminal:
The system proceeds to download the zipped package from the official page: Use a compression tool to unzip the content of the downloaded file and save it to the desired location on your system. The following command saves the extracted files in the Workbench folder on the Desktop:
sudo wget https://www.sql-workbench.eu/Workbench-Build125-with-optional-libs.zip
The output displays the extraction process. Windows & macOSUse your browser and access the official website with this link:https://www.sql workbench.eu/downloads.htmlSelect your preferred package from the list. The first option provides the most comprehensive bundle. Click and download the file. Right-click the zipped folder and extract the content to a preferred location on your system. In this example, the content was extracted to the Workbench folder on the desktop in Windows.
unzip Workbench-Build125-with-optional-libs.zip -d Desktop/Workbench
Step 2: Install Latest Java Version (Optional)SQL Workbench is based on Java. You need to have at least Java 8 on your system to be able to install and use SQL Workbench. If you already have an up to date version installed, you can skip to Step 3 of the tutorial.There is no need to download or install Java runtime beforehand. The SQL Workbench package already contains the necessary shell scripts: download_jre.sh and download_jre.cmd. These scripts when executed, automatically download and extract the latest available Java runtime.Ubuntu 18.04Use your command terminal to access the folder where you have extracted the SQL Workbench package. In our example, the files are in the Desktop/Workbench folder. Use the following command to initiate the shell script that downloads and extracts Java runtime:
The system runs the script and installs the latest available Java version. Windows & macOSAfter unpacking the archive, run the download_jre script from within the Workbench folder. The script downloads and extracts an appropriate Java runtime to the existing folder. The Windows launcher and shell scripts automatically use that specific Java runtime. Alternatively, use your browser to visit the official Oracle Java website. This method allows you to select a different Java version.
sudo sh download_jre.sh
Step 3: PostgreSQL JDBC PluginJDBC is a software component that enables Java to interact with the PostgreSQL database. Each database management system requires its JDBC driver. The SQL Workbench/J distribution does not contain the JDBC driver. It’s necessary to download the JDBC plugin manually.Ubuntu 18.04Enter the following command to download the latest drivers and save the postgresql-42.2.10.jar file in a PostgreJDBC folder:
The output from the terminal confirms that the file was successfully downloaded and saved. Windows & macOSDownload the latest driver version by using the provided link. Download and place the file in a secure folder. No installation is necessary. However, if the file gets accidentally deleted or moved, you are not going to be able to connect to your database with SQL Workbench.
wget -P Desktop/PostgreJDBC https://jdbc.postgresql.org/download/postgresql-42.2.10.jar
Step 4: Start SQL WorkbenchThere is no need to install SQL Workbench as it comes as a preconfigured .jar file that can be run in any Java runtime environment.Ubuntu 18.04Access the Desktop/Workbench folder and enter the following command in your terminal to initiate the SQL Workbench shell:
You have successfully launched the SQL Workbench command interface. You are now able to create a connection profile. Windows & macOSAccess the Workbench folder and start the SQLWorkbench.exe executable file. If you are using 64-bit Windows start the SQLWorkbench64.exe file.
sudo sh sqlworkbench.sh
Step 5: Connect to PostgreSQL Using SQL WorkbenchFrom this point, the SQL Workbench shell has the same functions, regardless of the system, you are running it on. The Select Connection Profile page allows you to define the information necessary to establish a connection to your PostgreSQL server.1. Define a unique name for the Connection Profile (in the example below: PostgreSQL Connection). 2. Open the Driver drop-down menu and select the PostgreSQL option.3. Click Manage Drivers and set the precise path to your JDBC PostgreSQL driver. 4. Enter the URL for your PostgreSQL server. The URL should be formatted as follows:
5. Enter the username and password for your database in their respective fields.6. Once you enter the details correctly, click OK to establish the connection.