DSC_0291 Zach Doty Cover Photo for Installing SQl Software PostgreSQl and pgAdmin

Downloading, Installing and Getting Started with PostgreSQL and pgAdmin

How to Download, Install and Get Started with PostgreSQL & pgAdmin, Popular SQL Programming Software

 

Introduction

Welcome back to the grand SQL journey! If you missed the beginning, here’s my previous post as a complete beginner to SQL. In this post, you will:

  • Learn what pgAdmin is
  • Become familiar with the program and some of its release history and
  • Walk through an installation of pgAdmin.

 

What is the pgAdmin SQL Software all about?

According to the educational material I’m working through, it’s commonplace (in some circles) to use a graphical user interface (GUI) when working with a SQL engine. (Compared to working with command line, zoinks!) That being said, pgAdmin is reportedly one of the most popular interfaces for PostgreSQL, the SQL engine / platform of choice listed out in the previous post. For the purposes of our education, I’ll be working in pg Admin 4.

 

Installation of PostgreSQL and pgAdmin

Here are the steps:

  • Install PostgreSQL and pgAdmin through their default Windows install methods. (Sorry Mac and Linux users, this party is PC only for now!)
  • Download a .tar file to be used for sample learning
  • Use the .tar file to restore a database we’ll be working with

 

Downloading PostgreSQL

First, head to https://www.postgresql.org/ in a new tab or window. When you’ve arrived, you should see something like the below screen, and click the “Download” link in the navigation.

2017-01-14-001-PostgreSQL-Download-Home-Screen-Shot

After arriving at the Download page, you should see the below. Under the “Binary Packages” for pre-built packages, select your appropriate operating system. Windows is shown below for the purposes of this demonstration. If you feel led or qualified to choose the source code option, you probably don’t need to be reading this article anyway. 🙂

2017-01-14-002-PostgreSQL-Download-Page-Windows-Install-Screen-Shot

Following the Windows link should take you to the Windows Installers page.  Under “Interactive installer by EnterpriseDB, click the “Download the installer” link. Another option for “Graphical installer by BigSQL” exists, but there have been some anecdotes of annoyances with the BigSQL experience.

2017-01-14-003-PostgreSQL-Download-Page-Windows-Installer-EnterpriseDB

Clicking on the link illustrated above should take you to the EnterpriseDB site, where a screen like the below should appear. When you first arrive, you will be prompted to select a version of PostgreSQL and your machine’s operating system details. Below, I’ve selected PostgreSQL 9.6.1 and Windows x86-32, because I’ve got a really old laptop! A quick note on the PostgreSQL version selection, you should choose the latest non-Beta version to install. As this post regards software and tech, it could quickly become outdated. When you have selected the appropriate details, click the ever-important “DOWNLOAD NOW” button.

2017-01-14-004-EnterpriseDB-PostgreSQL-Download-Page-Windows-Installer

After the .exe file downloads, open it, allow it to run. A screen for Microsoft Visual C++ Redistributable will likely appear, let it run and complete. Next, the PostgreSQL installation dialogue should appear. (Below.)

2017-01-14-005-EnterpriseDB-PostgreSQL-Installation-Starter

Accept the default installation and data directories, unless you have a weird and specific reason to do something else. After you do this, enter your desired password.

A quick and necessary aside. Please follow best practices for passwords and information security. It is your sole responsibility to do so: protecting your information and yourself. I accept neither liability nor responsibility, nor in whole, nor in part, for your password security. Be smart.

Okay, with that out of the way, proceed to the Port portion of Setup. Accept the default and proceed. After the port screen comes a locale configuration. Accept the default and proceed. Now, you should be to start the installation process. Click “Next >”!

Once you click install, you should see a pretty traditional installation progress screen that creates a ton of directories, unpacks HTML files, and so on. (Note: this took my machine 5 minutes or so to install.) If you care to do so, uncheck any mail subscription offers and finish the installation!

From here, you should be able to get to pgAdmin 4 from your Windows start menu. Tah-dah!

2017-01-15-006-pgAdmin4-PostgreSQL-Installation-Starter

If you expand the servers icon, you ought to see something along the lines of PostgreSQL9.6. If you click to expand the PostgreSQL 9.6 item, you should be prompted to enter your password. From there, you should see a dashboard with some various charts becoming populated, like below.

2017-01-15-007-pgAdmin4-PostgreSQL-Installation-Confirmation

Next, a sample database will be restored. As shown below, please right click “Databases”, then mouse over the menu item “Create” and click “Database”.

2017-01-15-008-pgAdmin4-PostgreSQL-Database-Creation

From there, name your database and save it! Once it’s successfully created, you should see a new part of the tree for your database, with options underneath such as Casts, Catalogs, Event Triggers, Extensions and so on.

2017-01-15-010-pgAdmin4-PostgreSQL-Database-Confirmation

To restore data into the database, right click the database name and select the restore option. First time users, you may see a dialogue box saying, “Configuration Required”. No worries here, we’ll get through that momentarily. Click File > Preferences > Paths > Binary Paths.

2017-01-15-012-pgAdmin4-PostgreSQL-Database-Binary-Paths

Once you’ve reached the point as described and shown above, you’ll need to open a new Explorer window. (Sorry, Mac and Linux folks, no guidance from me here.) Go to Computer > Program Files > PostgreSQL > 9.6 > bin. Copy the address and paste into the pgAdmin PostgreSQL Binary Path, click OK.

2017-01-15-013-pgAdmin4-PostgreSQL-Database-Binary-Paths-Computer

That should now allow you to restore a database. Now return to the above steps, and when you select restore, select the options as desired. You should see a processing dialogue and success message. When this is complete, right click the database name and select “Refresh”. Very important – think of like you needing to refresh the data sources when working with pivot tables in Microsoft Excel.

Okay, you should have your first database! right click the database name and select “Query Tool”. Let’s make our first SQL query FTW!

2017-01-15-014-pgAdmin4-PostgreSQL-Database-Success-First-Query

In the code window, type:

SELECT * FROM [table “” not found /]
;

Then, either select the lightning bolt and execute + refresh. Or, you could just press F5 and it accomplishes the same thing. If the query is successful and you didn’t misspell a simple table name like I did the first time, then you should see the table in the Data Output window.

 

Wrap-Up

Alrighty! How about a rip-roaring start into SQL? Excited to keep learning with you. Stay tuned. If you’re just arriving at this article, here’s my running list of articles that detail how to learn SQL.

 

 

1 reply

Trackbacks & Pingbacks

  1. […] (or SQL). Previously, I shared my notes on the absolute beginning point for starting SQL, and also getting started with PostgreSQl and pgAdmin. Now, we venture into some basics of database management via SQL: • Creating a database with […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply