small medium large xlarge

14 Dec 2011, 04:43
Michael Sergio (1 post)

I figured I’d share getting setup on my Ubuntu machine.


sudo apt-get install postgresql

Creating User

createdb book
createuser: could not connect to database postgres: FATAL:  role "myusername" does not exist


The bit above can be resolved with the following (replacing myusername for yours)

sudo -u postgres createuser myusername
Shall the new role be a superuser? (y/n) y


Then this should work

createdb book


Installing Extensions There should be more problems when trying to create the 5 extensions

psql book -c "CREATE EXTENSION tablefunc"
ERROR:  could not open extension control file "/usr/share/postgresql/9.1/extension/tablefunc.control": No such file or directory


You can fix it by just downloading a package.

sudo apt-get install postgresql-contrib 


Downloading the postgresql-contrib packages will give the ability to use the following five commands:

psql book -c "CREATE EXTENSION tablefunc"
psql book -c "CREATE EXTENSION fuzzystrmatch"
psql book -c "CREATE EXTENSION pg_trgm"
psql book -c "CREATE EXTENSION cube"
psql book -c "CREATE EXTENSION dict_xsyn"


And now you should be good to go!

Thanks to the post by Tanner Watson for the CREATE EXTENSION command

29 Dec 2011, 03:55
Sam McEwan (1 post)

Just wanted to hit you with a massive thank you. After hours of no joy this post was a godsend.

10 Oct 2012, 15:15
Arun Rangarajan (2 posts)

Thanks a ton, Michael! It works great for postgres 9.1!

Unfortunately I had to remove postgres 9.1 and install 8.4 for another project. 8.4 does not have CREATE EXTENSION.


sudo apt-get install postgresql-contrib-8.4

and then:

cd /usr/share/postgresql/8.4/contrib
psql -d book -f cube.sql
psql -d book -f tablefunc.sql
psql -d book -f fuzzystrmatch.sql
psql -d book -f pg_trgm.sql
psql -d book -f dict_xsyn.sql

Thanks to depesz’s answer here:

  You must be logged in to comment