PostgreSQL - Getting Started

PostgreSQL - Getting Started

PostgreSQL

Share

This is an introduction to PostgreSQL database.

What is PostgreSQL?

PostgreSQL is a RDBMS or Relational Database Management System. It is one of the popular and most advanced open source relational database and was developed at Berkeley Computer Science Department (University of California).

Versions of PostgreSQL

PostgreSQL can be installed on Windows, Mac and Linux personal computers and can also be installed on servers like Google Cloud, AWS (Amazon Web Services) etc.

PostgreSQL is free and open source. You can learn more about it on their licence page.

Requirement

To learn PostgreSQL you will need to install it on your computer. You can get the free version of PostgreSQL as per your operating system. Visit postgresql.org to download.

For Mac users

If you are on a Mac then you can install PostgreSQL using Homebrew. Check this tutorial How to install PostgreSQL on Mac using Homebrew.

You can also use Postgres.app an easy to use installer for Mac. Visit postgresapp.com to download.

Check out this tutorial on How to install Postgres.app to use PostgreSQL database on Mac

Root Account

During the installation you may have to set the password for the root account for your local PostgreSQL server.

I prefer to set the password as root123 for easy use.

Always set a strong password for your database when in production/development server.

Connecting to the database using psql

After installing the PostgreSQL database on your computer you can connect to it using psql command from your terminal.

Open the terminal and type the following command and it will connect you to the default database.

$ psql
psql (12.1)
Type "help" for help.

postgres=#

On my Mac the default database is set to postgres.

Install GUI softwares to connect to PostgreSQL database

We can use the terminal to connect to the database and run SQL queries. That's how it is generally done when we connect to remote servers. But if you want to install GUI (Graphical User Interface) then you can pick the following softwares.

  • pgAdmin
  • DBeaver
  • Navicat
  • DataGrip

There are many more softwares available. Some are free and some are paid. Choose accordingly.

Alright, in the next tutorial we will learn to work with databases in PostgreSQL. See you there. Have fun learning.

Share