How to install the additional module pg_trgm

pg_trgm is an extension, so:

CREATE EXTENSION pg_trgm;

If you get the following error

ERROR: could not open extension control file ".../extension/pg_trgm.control":
No such file or directory"

then you need to install the module for your operating system

  • Ubuntu/Debian:

    sudo apt install postgresql-contrib
    
  • Redhat/Centos

    sudo dnf install postgresql10-contrib
    
  • Fedora

    sudo dnf install postgresql-contrib
    

1) Log into postgres

psql -U <DB_USERNAME>

2) After you are connected, switch to the DB you want to install the extension for:

\c <DB_NAME>

3) Then install the extension as answered previously:

CREATE EXTENSION pg_trgm;

Installing the extension initially gave me issues because I was not doing step 2. I thought the installation was a global thing but it seems its per DB