Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Faisal M
Author

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Share


Tags


avrt

How to install Postgres 12 on Ubuntu 18.04

Faisal MFaisal M

PostgreSQL 12 is out and has packed a lot of nice features and improvements. This is a quick tutorial to help You get started with PostgreSQL 12 in no time.

sudo apt-get -y install bash-completion wget

Add the GPG key and PostgreSQL 12 repository by running the commands below.

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list

The repository added contains a few different packages including third party addons.

  • postgresql-client
  • postgresql
  • libpq-dev
  • postgresql-server-dev
  • pgadmin packages

Lets update the APT repository index and install the packages related to PostgreSQL

sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12

Check that the Postgres service is up and running

sudo systemctl status postgres

It should respond with the output below

faisal@berra:~$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2019-09-30 10:45:27 CEST; 2 weeks 3 days ago
 Main PID: 2104 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/postgresql.service

Sep 30 10:45:27 berra systemd[1]: Starting PostgreSQL RDBMS...
Sep 30 10:45:27 berra systemd[1]: Started PostgreSQL RDBMS.

Now You can run sudo su postgres to change to the postgres system user and with that user You can access the Postgres CLI via psql

sudo su postgres
psql

And You should get the output shown below

postgres@berra:$ psql
psql (12.0 (Ubuntu 10.10-0ubuntu0.18.04.1))
Type "help" for help.

That's it, you are done. You can now utilize the full power of Postgres 12!

Happy coding!

Faisal M
Author

Faisal M

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

View Comments