In this article, we will guide you through the process of installing PostgreSQL 13 on Ubuntu 20.04. PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale complicated data workloads.
To install PostgreSQL 13 on Ubuntu 20.04, you need to add the PostgreSQL apt repository, import the repository signing key, update the package list, and then install PostgreSQL 13 using the apt-get command. Finally, verify the installation by checking the status of the PostgreSQL service.
Before starting, ensure that you have superuser (root) access to your Ubuntu 20.04 system. If you’re using a personal system, you should be the superuser.
Step 1: Adding PostgreSQL Apt Repository
PostgreSQL is available in all Ubuntu versions by default. However, Ubuntu 20.04 includes PostgreSQL 12 by default. To install PostgreSQL 13, we need to add the PostgreSQL apt repository manually.
Open your terminal and execute the following command:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
This command adds the PostgreSQL apt repository to your system’s sources list. The
$(lsb_release -cs) part automatically fetches your Ubuntu version.
Step 2: Importing Repository Signing Key
Next, we need to import the repository signing key. The PostgreSQL packages are signed by a key to ensure their authenticity. Run the following command to import this key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
wget command fetches the key, and
sudo apt-key add - adds it to your system’s list of trusted keys.
Step 3: Updating Package List
After adding the repository and its key, update your system’s package list using the following command:
sudo apt-get update
This command fetches the latest updates from all repositories, including the newly added PostgreSQL repository.
Step 4: Installing PostgreSQL 13
Now, you can install PostgreSQL 13 by running:
sudo apt-get -y install postgresql-13
-y option automatically answers ‘yes’ to all prompts, allowing the installation to proceed without your intervention.
Step 5: Verifying Installation
After the installation is complete, verify that PostgreSQL 13 is installed and running with the command:
sudo systemctl status postgresql
This command shows the status of the PostgreSQL service. If everything went well, you should see that the service is active (running).
Congratulations! You have successfully installed PostgreSQL 13 on your Ubuntu 20.04 system. You can now start using PostgreSQL for your database needs. For more information on how to use PostgreSQL, you can visit the official PostgreSQL documentation.
Remember, it’s important to keep your system and software updated to ensure you have the latest features and security patches. You can update PostgreSQL through your package manager like any other software on your system.
We hope this article was helpful. If you encounter any issues, feel free to leave a comment below.
Yes, you can install PostgreSQL 13 on other Ubuntu versions by following similar steps. However, you may need to adjust the repository URL and key accordingly.
You can check the version of PostgreSQL installed on your system by running the command
psql --version in the terminal.
Yes, it is possible to have multiple versions of PostgreSQL installed on the same system. However, you need to ensure that they are installed in separate directories and use different ports to avoid conflicts.
To start the PostgreSQL service, you can use the command
sudo systemctl start postgresql. To stop the service, you can use
sudo systemctl stop postgresql.