How to install PostgreSQL with pgvector on Ubuntu - Rocketeers

 On this page

 Knowledge
---------

How to install PostgreSQL with pgvector on Ubuntu
=================================================

### [\#Databases](http://rocketee.rs/index.php/databases)

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

 Published by Mark van Eijk on December 2, 2023 
Updated on January 6, 2025 · 1 minute read

1. [Install PostgreSQL](#content-install-postgresql)
2. [Install pgvector](#content-install-pgvector)
3. [Enable the pgvector extension](#content-enable-the-pgvector-extension)
4. [Start PostgreSQL automatically (optional)](#content-start-postgresql-automatically-optional)

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

[\#](#content-install-postgresql "Permalink")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

```

[\#](#content-install-pgvector "Permalink")Install pgvector
-----------------------------------------------------------

When PostgreSQL is installed, run the following command:

 ```
sudo apt install postgresql-17-pgvector

```

[\#](#content-enable-the-pgvector-extension "Permalink")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

```

[\#](#content-start-postgresql-automatically-optional "Permalink")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!

  Fill in your email address to receive updates  Subscribe 

#### Related articles

[Stream MySQL backup directly to S3 bucket](http://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)
-------------------------------------------------------------------------------------------------------

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

[Read more →](http://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)

[Export MySQL database using command line](http://rocketee.rs/index.php/export-database-mysql-command-line)
-----------------------------------------------------------------------------------------------------------

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

[Read more →](http://rocketee.rs/index.php/export-database-mysql-command-line)
