Knowledge

How to install PostgreSQL with pgvector on Ubuntu 22

#Databases

Turn PostgreSQL in a vector database using the pgvector extension on Ubuntu 22.

Published by Mark van Eijk on December 2, 2023 · 1 minute read

  1. Install PostgreSQL
  2. Install pgvector
  3. Enable the pgvector extension
  4. Start PostgreSQL automatically (optional)

We assume you already have provisioned a Ubuntu 22.x server, ready to get going.

Install PostgreSQL

If you haven't already installed PostgreSQL on your server, execute these commands to install it from the official repository:

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

Install pgvector

When PostgreSQL (version 15) is installed, run the following command:

sudo apt install postgresql-15-pgvector

Enable the pgvector extension

The last step to turn PostgreSQL in a vector database, run the following query as the postgres user:

sudo -u postgres psql # run as postgres user
CREATE EXTENSION vector; # create the vector extension

Start PostgreSQL automatically (optional)

Configure PostgreSQL to start automatically after booting your server:

sudo systemctl enable postgresql
sudo service postgresql start

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

Stream MySQL backup directly to S3 bucket

Turn PostgreSQL in a vector database using the pgvector extension on Ubuntu 22.

Read more →

Exporting database in MySQL using command line

Turn PostgreSQL in a vector database using the pgvector extension on Ubuntu 22.

Read more →