Skip to content
Alfred Nutile edited this page May 26, 2023 · 3 revisions

Forge

For simplicity sake I use Forge to manage many database. When done setting up a Database server Postgres v15.

You can run this recipe:

#!/bin/bash

# Define your database password and name here
DB_PASSWORD=""
DB_NAME=""

# Update package list
apt update
apt install postgresql-15-pgvector


export PGPASSWORD=$DB_PASSWORD && sudo -u postgres psql -d $DB_NAME -c "CREATE EXTENSION vector;"

echo "PostgreSQL and Vector installation complete"

Oh oh

If that does not work try:

The command sudo apt-get install postgresql-server-dev-15 is for installing the PostgreSQL development package, which includes header files and libraries necessary to compile PostgreSQL and extensions.

It doesn't install the pgvector extension. pgvector (as of my knowledge cutoff in September 2021) needs to be built from source and then installed.

Here's a recap on how to do that:

  1. Install dependencies:

    sudo apt-get install git gcc postgresql-server-dev-15 libpq-dev
  2. Clone the pgvector repository and build the extension:

    git clone https://github.com/ankane/pgvector.git
    cd pgvector
    make
    sudo make install

After these steps, you should be able to find pgvector.control and pgvector--*.sql in the directory /usr/share/postgresql/15/extension/, which are the files needed to install the pgvector extension in a PostgreSQL database.

Finally, log into your PostgreSQL database and run the SQL command to enable the extension:

CREATE EXTENSION pgvector;