Skip to main content

Installing PostgreSQL and TimescaleDB in Ubuntu

To follow the latest instructions, view the instructions on the PostgreSQL and TimescaleDB sites here where the following summarized instructions were taken from:

https://www.postgresql.org/download/linux/ubuntu/

https://docs.timescale.com/self-hosted/latest/install/installation-linux/

Install PostgreSQL

To install PostgreSQL, use the following script:

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
sudo apt install -y postgresql-17

To set the password for the default PostgreSQL user run the following command:

sudo -u postgres psql

Then in the PSQL console, enter to set a new password:

\password postgres

Then enter this to exit the console:

\quit
Install TimescaleDB

To install TimescaleDB, use the following script:

sudo apt install -y gnupg apt-transport-https lsb-release wget
echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg
sudo apt update
sudo apt install -y timescaledb-2-postgresql-17 postgresql-client-17

To tune TimescaleDB for the current server configuration and restart PostgreSQL, run the following commands:

sudo timescaledb-tune --quiet --yes
sudo systemctl restart postgresql