
In this tutorial, we are going to show you how to install PostgreSQL 9.6 on Ubuntu 20.04. We will explain what PostgreSQL stands for and the steps of its installation, configuration, and use.
Postgres or PostgreSQL is an object-relational database management system that stores and retrieves information. This system is suitable for storing a big amount of data, it is open source and is very powerful and reliable.
The installation will take no more than 5 minutes. Let’s Start!
Table of Contents
Prerequisites
- Fresh install of Ubuntu 20.04
- User privileges: root or non-root user with sudo privileges
Step 1. Update the System
Since this is a fresh install of Ubuntu 20.04 we need to update the system to its latest version and be sure the software is up to date.
After executing the command it will take some time for the system to get the latest information.
Step 2. Import PostgreSQL 9.6 GPG public key
The signing GPG key can be added with the following command:
Step 3. Add PostgreSQL 9.6 repository
By default, Ubuntu 20.04 does not have the PostgreSQL repo and we need to add it manually so we can install it later.
Once the repository is added update the system.
Step 4. Install PostgreSQL 9.6
Now the GPG key and the repo are added and we are ready to install PostgreSQL 9.6 on our Ubuntu 20.04
The command above will completely install the PostgreSQL database server and other required database modules and tools.
Step 5. Check and verify the Installation
First of all, you need to know that PostgreSQL is working on port 5432.
To check this you can execute the command below:
The output should be:
We can see that the Postgres service is running on port 5432 successfully.
If you want to check and verify that the correct version is installed, please execute:
The output should be:
Once everything is installed and prepared we can go to the next step, and that step is how to manage the PostgreSQL service.
Step 6. Manage PostgreSQL 9.6 service on Ubuntu 20.04
Here are some basic commands on how to manage the PostgreSQL services like status, starting, stopping, and restarting.
To check the status of the PostgreSQL service:
The output should be similar to the output below:
To stop the PostgreSQL service.
There will be no output but if you check the status of the service there will be minor changes from the previous output.
To start the PostgreSQL service:
To restart the PostgreSQL service:
If you want the PostgreSQL service to run on system boot you need to enable it and it can be done with the following command:
Step 7. Configuration of PostgreSQL 9.6 and console
If you want to make any changes in the configuration file of Postgres services like accessibility, authentication, connectivity, or resource usage then you need to open the “/etc/postgresql/9.6/main/postgresql.conf” with some editor and make the necessary changes.
To access the console of the PostgreSQL service you need to log in as “postgres” user and execute the following commands:
The output should be:
Now, you can list the default databases with the “\l” command and the output will be similar to the output below:
To quit from the PostgreSQL shell just type “\q“.
Done. You successfully installed and managed the PostgreSQL 9.6 service on Ubuntu 20.04.
Of course, you don’t have to install PostgreSQL 9.6 on Ubuntu 20.04, if you use one of our PostgreSQL VPS Hosting plans, in which case you can simply ask our expert Linux admins to install PostgreSQL 9.6 on Ubuntu 20.04 for you. They are available 24×7 and will take care of your request immediately.
If you liked this post on how to install PostgreSQL 9.6 on Ubuntu 20.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Also, feel free to check out our post on how to install PostgreSQL on Debian 9. Thanks.
Thank you so much for sharing this tutorial, I have office website which still use this version 9.6, really help to do my work and now I will search for your tutorial to install phppgadmin:) . Only one more case for me in this install, I found that there were 2 version installed, version 12 and 9.6, I need to find out how to use the version 9.6. Great sharing, success always..