If you want to use the official repository for Postgresql, the following link has very good instructions for all supported operating systems. https://www.postgresql.org/download/
NOTE: As of Debian 10, the OLD version of Postgresql v11 is in their repositories your safest bet is to get the latest from postgresql.org.
These instructions were taken straight from their website for Debian. Ubuntu may vary slightly.
If you're on an Debian-like machine, you should be able to install
PostgreSQL like this:
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql libpq-dev
If you're on OSX and using brew
, do
$ brew update
$ brew install postgres
For Gentoo (eselect-postgresql is optional),
# emerge --sync
# emerge -av postgresql eselect-postgresql
For Fedora/CentOS/RHEL, do
# dnf install postgresql-server postgresql-contrib
For Arch/Manjaro, do
$ pacman -S postgresql
For Windows, just download the installer here and run it. After installing, make sure to add the /lib directory to your PATH system variable.