Install PostgreSQL 17 on Ubuntu 24.04
1. Import the repository signing key:
$ sudo apt install curl ca-certificates
$ sudo install -d /usr/share/postgresql-common/pgdg
$ sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
2. Create the repository configuration file:
$ sudo sh -c ' echo "deb [arch=amd64 signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
3. Update the package lists:
4. Install PostgreSQL 17:
# If you want the latest version, use 'postgresql' instead of 'postgresql-17'
$ sudo apt -y install postgresql-17
5. Verify PostgreSQL installation:
$ sudo systemctl status postgresql
6. Check the PostgreSQL version:
Update PostgreSQL Admin User Password
2. Set password for postgres
user:
postgres=# ALTER USER postgres PASSWORD 'root';
postgres=# \q