Postgresql 9.1 Adminpack Install

everywhere I see guides for postgre, it seems to be on version 8.4. In that case the instruction is:

sudo -u postgres psql < /usr/share/postgresql/8.4/contrib/adminpack.sql

that location doesn't exist in the 9.1 directory apparently.

Can anyone point me how to get it working (needed for pgadmin)?

3 Answers

admin pack can be found in /usr/share/postgresql/9.1/extension

To install

sudo -u postgres psql

CREATE EXTENSION adminpack;

Also to see a list of installed extensions select * from pg_extension;

1

The answer above works great. You just have to remember that you need to do this for every database, as the extensions are installed per database. The instructions above install the extensions in the database named postgres. To install it in your database just switch to your database:

\c yourdb and repeat the process: CREATE EXTENSION adminpack On Ubuntu the admin pack is in the postgresql-contrib package.

First, if you haven't installed contrib:

sudo apt-get install postgresql-contrib

To iterate over several databases:

sudo su postgres;
for db in $(psql -c "SELECT datname FROM pg_database WHERE datistemplate = false;" | sed '1,2d' | head -n -2 | grep -v '^ postgres$'); do
  echo "Adding adminpack to ${db}"
  psql -c "CREATE EXTENSION adminpack;" ${db};
done

As a one(ish)-liner:

sudo su postgres;
for db in $(psql -c "SELECT datname FROM pg_database WHERE datistemplate = false;" | sed '1,2d' | head -n -2 | grep -v '^ postgres$'); do psql -c "CREATE EXTENSION adminpack;" ${db}; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest