Postgres pgcrypto privliledges

Doo Dah picture Doo Dah · Sep 14, 2015 · Viewed 7.4k times · Source

I intsalled the pgcrypto extension as the superuser like this:

CREATE EXTENSION pgcrypto;

As the superuser, I tested it, and it works find:

select gen_salt('bf');
           gen_salt
-------------------------------
 $2a$06$CJPcLcOBZnCEl.Z5ChrSbO

But, when logging in as a different user, I get an error as follows:

select gen_salt('bf');
ERROR:  function gen_salt(unknown) does not exist

How do I make the pgcrypto library visible to all users?

Thanks.

Answer

Sami Kuhmonen picture Sami Kuhmonen · Sep 14, 2015

PostgreSQL extensions are per database. If you log in to another database, the extension is not available there. By default the functions are usable by any user.