My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Simple PostgreSQL Installation Guide ~ Golang

Marvin Collins Hosea's photo
Marvin Collins Hosea
·Aug 18, 2021·

3 min read

The first thing you need to have in your local dev environment before starting developing any database-oriented application is a database installed in your machine/laptop. Well, that's obvious and doesn't hurt to state it.

This is the first post in Golang series and I might write random posts on what I am working on or something new to me. I am writing these as a reminder or articles I might refer to later, hopefully, you will learn something along the way.

Have worked with different databases like MSSQL, MySQL, CockroachDB, and MongoDB in my career, but I majorly use MySQL - My primary language is Golang and PHP. But I realized PostgreSQL is the most commonly used database in the Golang community. Hence I had to give it a try. I want to be honest, I've not benchmarked PostgreSQL performance against any other database have used, so I cannot give you the pros and cons of PostgresSQL, I might write a follow-up article after trying it out or you can make google your friend and find out, for now, let's stick to installing PostgreSQL into your machine.

FYI; You can install PostgreSQL alongside MySQL and/or you can pull PostgreSQL docker image from docker hub

docker pull postgres

PostgreSQL Installation

Currently, I am using Fedora 32. And at the time of writing this article, PostgreSQL stable version is 13.

Choose your OS - I assuming that you're doing PostgreSQL dev installation, I have not considered PostgreSQL server setup but still, you can still use this guide for PostgreSQL dev, staging server installation.

1. Windows
  • Download the installer from this link postgresql.org/download/windows
  • The installer will come with pgAdmin which is GUI for PostgreSQL management
  • It will also come with StackBuilder package manager that can use to install more PostgreSQL tools and drivers as stated in the link above.
  • Follow the installation and jump to the Setting user account.
2. macOS
  • You can use Homebrew to install PostgreSQL by running
    brew install postgresql
    
    or download the installer from this link postgresql.org/download/macosx
3. Ubuntu/Debian
  • PostgreSQL is included in Ubuntu by default.
  • You can apt or apt-get to install PostreSQL in your Ubuntu OS Update your package list first
    sudo apt update
    
    or
    sudo apt-get update
    
    Once you've updated your package list, install PostgreSQL.
    sudo apt -y install postgresql
    
    or
    sudo apt-get -y install postgresql
    
    -y flag assume yes to any prompt non-interactively

If you want to install a specific version of PostgreSQL, you can change the last digit which is the version number, here is an example

sudo apt -y install postgresql-12
4. Red Hat Enterprise Linux/Fedora/CentOS/Oracle Linux

This is the first part of this series and will share more on the next scheduled post.

For more information

Follow the instructions on this page postgresql.org/download/linux/redhat computingforgeeks.com/how-to-install-postgr.. postgresql.org/download/linux/ubuntu computingforgeeks.com/how-to-install-postgr..