Empowering you to understand your world

PostgreSQL Tutorials: How To Install PostgreSQL On Linux

By Nicholas Brown.

You can install PostgreSQL on Linux using multiple methods, including compiling it from source, using your Linux distribution’s built-in package manager (Ubuntu/Debian’s Aptitude, Gentoo’s Ebuild, or Fedora/RedHat’s RPM), or you can use PostgreSQL’s official repository with your operating system’s built-in package manager.

How To Install PostgreSQL From The Ubuntu Repository

You can install PostgreSQL using only one command if you are using the built-in Ubuntu repository as shown below:

sudo apt install postgresql

How To Install PostgreSQL From PostgreSQL’s Repository

If you’re willing to type a few extra commands, i’d recommend the official PostgreSQL repository because it will get the latest version before the built-in repositories will:

The following commands will set up PostgreSQL’s official repository. Note that the ‘-y‘ command after ‘apt-get’ will install it without confirmation and you can remove that if you wish.

PostgreSQL Tutorial: How To Create A User In PostgreSQL

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

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

 

Subscribe to our newsletter
Get notified when new content is published