# Postgresql install errors on Ubuntu 16.04

**URL:** https://meta.discourse.org/t/postgresql-install-errors-on-ubuntu-16-04/70846
**Category:** Development
**Created:** [September 27, 2017, 3:13am UTC](https://meta.discourse.org/t/postgresql-install-errors-on-ubuntu-16-04/70846 "2017-09-27T03:13:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [September 27, 2017, 3:13am UTC](https://meta.discourse.org/t/postgresql-install-errors-on-ubuntu-16-04/70846/1 "2017-09-27T03:13:00Z")

</div>

While trying to install Discourse on my laptop (Ubuntu 16.04) using [this guide](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md), I got some errors like this:

```
PG::InsufficientPrivilege: ERROR: permission denied to create extension "hstore"

```

and:

```
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: database "discourse_test_multisite" does not exist

```

I got rid of the errors by changing this:

```
# Postgresql
sudo su postgres
createuser --createdb --superuser -Upostgres $(cat /tmp/username)
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
exit

```

to this:

```
# Postgresql
sudo su - postgres
createuser --createdb --superuser -Upostgres $(cat /tmp/username)
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test_multisite owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test -c "CREATE EXTENSION hstore;"
psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"
exit

```

Diff:

```
2c2
< sudo su postgres
---
> sudo su - postgres
6a7
> psql -c "create database discourse_test_multisite owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
8a10,13
> psql -d discourse_test -c "CREATE EXTENSION hstore;"
> psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
> psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
> psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"

```

I’m too new to Rails/Discourse to know if it’s just my laptop or if I should add them to the docs, but I’ll leave the fix here in case someone else finds it useful. 🙂

(If it’s something that should go in the docs, let me know and I could make a pull request.)

---

<div class="post-metadata">

### Author: ![Phlegz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/phlegz/32/80119_2.png) [@Phlegz](https://meta.discourse.org/u/Phlegz)
#### Post date: [October 8, 2017, 12:26am UTC](https://meta.discourse.org/t/postgresql-install-errors-on-ubuntu-16-04/70846/2 "2017-10-08T00:26:53Z")

</div>

> [@j127](#):
>
> createuser --createdb --superuser -Upostgres $(cat /tmp/username)

I was getting the same error but I realized my problem was that I initially had a role with my username so what I needed to do was to drop that role in postgres and then follow the steps again:

# Postgresql  
sudo -u postgres -i  
createuser --superuser -Upostgres $(cat /tmp/username)  
psql -c “ALTER USER $(cat /tmp/username) WITH PASSWORD ‘password’;”  
exit
