Skip to content

Instantly share code, notes, and snippets.

@aleph-naught2tog
Created January 1, 2019 18:11
Show Gist options
  • Save aleph-naught2tog/a7825cb930f453388058886eb07b40fe to your computer and use it in GitHub Desktop.
Save aleph-naught2tog/a7825cb930f453388058886eb07b40fe to your computer and use it in GitHub Desktop.
"Role 'postgres' does not exist"

Postgres

This was initially specifically in relation to errors when setting up Phoenix/Mix in relation to Postgres.

  • role "postgres" does not exist" : https://hexdocs.pm/phoenix/phoenix_mix_tasks.html#ecto-specific-mix-tasks
    • Try logging in by running psql manually first.
    • If that doesn't work, try:
      1. From the command line: psql -d template1: this logs you into a default database.
      2. Now EXIT psql by doing \q; from their shell; we just logged in to make sure it was possible at all.
      3. From the command line: createdb. This creates the default database for the user you are currently logged in as.
      4. Try psql again -- you should login fine.
      5. From inside psql, do: create role postgres login createdb; This creates a user/role under the name of postgres, to whom we give the ability both to login and to create databases.
      6. \q; to exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment