Created
June 17, 2020 21:03
-
-
Save derigible/0667a03b2cbf1db29e0506aea5364226 to your computer and use it in GitHub Desktop.
rails PG::ConnectionBad (FATAL: role "" does not exist)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Likely you created a rails project with --database=postgresql | |
// If you haven't yet, setup a password for the postgres user, you can get into psql this way | |
$ sudo -u postgres psql | |
// Create the role | |
$ postgres=# CREATE ROLE <role> CREATEDB LOGIN PASSWORD 'password'; | |
CREATE ROLE | |
// OR, if your user has been setup you can use the createuser util that comes with postgres | |
$ sudo -u postgres createuser -d -l -P <role> | |
Enter password for new role: | |
Enter it again: | |
// To check that your roles exist | |
$ sudo -u postgres psql | |
\dg | |
Role name | Attributes | Member of | |
-----------+------------------------------------------------------------+----------- | |
<role> | Create DB | {} | |
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment