# Postgresql setup

**URL:** <https://discuss.circleci.com/t/postgresql-setup/16944>\
**Category:** Databases\
**Tags:** postgresql, circle-yml\
**Created:** [September 29, 2017, 12:58am UTC](https://discuss.circleci.com/t/postgresql-setup/16944 "2017-09-29T00:58:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apostopher](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/apostopher/32/17138_2.png) [@apostopher](https://discuss.circleci.com/u/apostopher)\
**Post date:** [September 29, 2017, 12:58am UTC](https://discuss.circleci.com/t/postgresql-setup/16944/1 "2017-09-29T00:58:08Z")

</div>

hello i’m trying to configure postgres 9.6 on circleCI, however i get the error `unknown user: postgres`. My circleCI config is:

```
- image: postgres:9.6
# other config
- run:
      name: Setup postgresql user
      command: sudo -u postgres psql -p 5432 -c "create user testuser with password 'testpass';"
      command: sudo -u postgres psql -p 5432 -c "alter user testuser with superuser;"
      command: sudo -u postgres psql -p 5432 -c "create database testdb;"
      command: sudo -u postgres psql -p 5432 -c "grant all privileges on database testdb to testuser;"
```

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [September 29, 2017, 2:19am UTC](https://discuss.circleci.com/t/postgresql-setup/16944/2 "2017-09-29T02:19:46Z")

</div>

Hello,

The `run` section is running on the first image which I assume is not Postgres. the best way to add a customer user and a database is to set them as ENVARS as [described here](https://hub.docker.com/_/postgres/) and [show here](https://circleci.com/docs/2.0/postgres-config/#postgresql-circleci-configuration-example).

---

<div class="post-metadata">

**Author:** ![apostopher](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/apostopher/32/17138_2.png) [@apostopher](https://discuss.circleci.com/u/apostopher)\
**Post date:** [September 29, 2017, 10:39pm UTC](https://discuss.circleci.com/t/postgresql-setup/16944/3 "2017-09-29T22:39:50Z")

</div>

Thanks, @levlaz I configured the ENVVARS and its working perfectly! cheers!

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [September 29, 2017, 10:54pm UTC](https://discuss.circleci.com/t/postgresql-setup/16944/4 "2017-09-29T22:54:47Z")

</div>

Glad to hear that it worked for you. Happy hacking 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:41am UTC](https://discuss.circleci.com/t/postgresql-setup/16944/5 "2018-06-18T11:41:49Z")

</div>

Closed on June 18, 2018, 11:41am UTC


