Install Postgres SQL on ubuntu

PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license. PostgreSQL contains many advanced features, is very fast and standards compliant.


PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features.


PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows.


PostgreSQL has bindings for many programming languages such as C, C++, Python, Java, PHP, Ruby and now it’s possible to develop Core C# Web Applicaitons using Entity Framework Core to make use of Postgres databases. It can be used to power anything from simple web applications to massive databases with millions of records.


In this post I will provide instructions on how to install Postgres on a ubuntu 16.04 laptop to enable development of core applications using Postgres SQL backend databases.

Installation of Postgres SQL

The Ubuntu Documentation also provides instructions on how to install Postgres SQL . However I will provide some quick start installations that I use to get my laptop ready for development.

This will install the latest version available in your Ubuntu release and the commonly used add-ons for it.

postgresql – core PostgreSQL engine and RDBMS around which everything else is build. The core files for this database server is installed in this package.

postgresql-contrib – additional packages that are provided by the team to work with database server.

pgadmin3 – a comprehensive PostgreSQL database design and management system for *nix and Windows systems. It is freely available under the terms of the Artistic Licence and may be redistributed provided the terms of the licence are adhered to.

Only install pgadmin3 on a development workstation, do not install on a headless production server

Connect to Postgres SQL

After installing PostgreSQL database server, by default it creates a user postgres with role postgres. It also creates a system account with same name postgres. So to connect to postgres server, login to your system as user postgres and connect database.

To start off, we need to set the password of the PostgreSQL user (role) called “postgres”; we will not be able to access the server externally otherwise. As the local “postgres” Linux user, we are allowed to connect and manipulate the server using the psql command.

this connects as a role with same name as the local user, i.e. “postgres”, to the database called “postgres” (1st argument to psql).

Set a password for the “postgres” database role using the command:

and give your password when prompted. The password text will be hidden from the console for security purposes.

To exit use either Ctrl + D or \ + q at posgreSQL prompt.

Once login is confirmed we can then check login info using following command from database command prompt.

If you see details similar to the above then your Postgres SQL has been installed successfully.

Create your account

For development purposes you probably don’t want or need to allow for other machines or user accounts to access your Postgres Database. So you may only want to allow access to your databases via your logged on user account.

Client programs, by default, connect to the local host using your Ubuntu login name and expect to find a database with that name too. So to make things REALLY easy, use your new superuser privileges granted above to create a database with the same name as your login name:

You can now \ & q and exit to get back to terminal

Pg Admin console

Start the pgadmin3 console from the terminal

This should start the application and you should be presented with the management screen

You can now connect to your instance by clicking on the plug icon and entering a name and the username and password.

Gary Woodfine

Freelance Full Stack Developer at
Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.

Affiliate Disclaimer

Disclosure: Please note that some of the links included in the blog posts are affiliate links, which means I will earn a commission if you decide to make a purchase.

I only include affiliate links to products, services and companies that I have personal experience and have actually used. I only recommend them because they are helpful and useful, not because of the small commissions I make if you decide to buy something.

Please do not spend any money on these products unless you feel they are relevant, suitable and will help you achieve your goals.

Buying anyone of these products and the commisions earned will not make me an overnite multi millionaire, but they will help to cover the hosting costs and compensate for the countless hours and effort I put in to create meaningful and valuable free content I provide to help others succeed.

You've also undoubtedly noticed that I also use various advertising networks - unless of of course you're using an Ad blocker, this is also an attempt to reduce my monthly deficit I experience in providing free relevant, valuable and on occassion insightful content for the benefit of others.

I only really make some money if people click on the ads, unless of course you consider 1c per 1000 impressions real money!

Bear in mind just how many impressions I need to make before I can cover my £20 hosting costs a month!

If you are using an adblocker and guilt stricken you can of course donate using any of the buttons below, but I won't be holding my breath.

Buy me a coffeeBuy me a coffee