PostgreSQL or Postgres, is a very powerful, highly scalable relational database system, that provided implementation of SQL query language. It is open source & can be installed on Unix/Linux system as well as on Windows systems. It is a popular choice for small & large organisations alike. In this tutorial, we will learn to install PostgreSQL on Ubuntu systems.
In our earlier tutorial, we have already discussed the installation of PostgreSQL on CentOS/RHEL systems.
Recommended Read : How to install CouchDB (& GUI manager) on CentOS & Ubuntu
Also Read :Create your own personal Cloud: Install OwnCloud
Install PostgreSQL on Ubuntu
We can easily install PostgreSQL with the default package manager in Ubuntu i.e. apt. We will be discuss how we can install PostgreSQL with apt using,
1- Default Ubuntu system repository
2- Official PostgreSQL repositories
1- Install PostgreSQL using default apt repositories
To install postgresql on Ubuntu, execute the following commands from terminal,
$ sudo apt-get install postgresql postgresql-contrib
That’s it for installation, postgres service by itself , now enable it for boot time,
$ sudo systemctl enable postgresql
Using the default Ubuntu repos, we have install PostgreSQL on Ubuntu but it’s not the latest stable version (which at time of writing this tutorial is 10), the installed version is 9.5. Now if need to install PostrgreSQL on Ubuntu with latest version, we will need to use the second method i.e. by using the official repos for Postgres.
2- Install PostgreSQL using the official repository
We will first need to add a new file called ‘pgdg.list’ in the folder ‘/etc/apt/sources.list.d/’, this file will hold repository information. Now based on the Ubuntu version being used make one of the following entries into the file,
$ sudo nano /etc/apt/sources.list.d/pgdg.list
For Ubuntu 14.04
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
For Ubuntu 16.04
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main'
For Ubuntu 17.04
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main'
For Ubuntu 18.04
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main'
Now import the repository signing key with the following command,
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
& than update the package list,
$ sudo apt-get update
Now we can install PostgreSQL on Ubuntu system,
$ sudo apt-get install postgresql-10
This will install postgresql, now enable it for boot time (service is started itself),
$ sudo systemctl enable postgresql
Our database is now ready to use & we now end this tutorial on how to install PostgreSQL on Ubuntu. In our coming tutorial, we will learn some important commands that are used for PostgreSQL administration. For this tutorial, please mention your questions/queries & also suggestions using the comment box below.
If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus
Donate us some of your hard earned money: [paypal-donation]
Linux TechLab is thankful for your continued support.
Also learn to install . postgresql from source,
https://thelinuxgurus.com/recommended-guide-to-install-postgresql-from-source/