PostgreSQL is a powerful open-source relational database known for extensibility, standards compliance, and support for advanced data types including JSON and arrays. The PostgreSQL Global Development Group maintains a dedicated APT repository with the latest releases. This guide installs PostgreSQL from the PGDG repository, secures the installation, and creates a database with a dedicated user. By the end, you'll have a hardened PostgreSQL instance with a working database ready for application use.
Install PostgreSQL
The PostgreSQL Global Development Group provides an official APT repository with the latest PostgreSQL releases.
1. Update the APT package index:
$ sudo apt update
Enter fullscreen mode
Exit fullscreen mode
2. Install the PostgreSQL common package:
$ sudo apt install postgresql-common -y
Enter fullscreen mode
Exit fullscreen mode
3. Run the repository setup script:
$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
Enter fullscreen mode
Exit fullscreen mode
4.…