Rails and PostgreSQL: Role postgres does not exist

前端 未结 13 2183
一整个雨季
一整个雨季 2020-12-07 07:51

I have installed PostgreSQL on my Mac OS Lion, and am working on a rails app. I use RVM to keep everything separate from my other Rails apps.

For some reason when I

13条回答
  •  猫巷女王i
    2020-12-07 08:55

    The installation procedure creates a user account called postgres that is associated with the default Postgres role. In order to use Postgres, you can log into that account. But if not explicitly specified the rails app looks for a different role, more particularly the role having your unix username which might not be created in the postgres roles.

    To overcome that, you can create a new role, first by switching over to the default role postgres which was created during installation

    sudo -i -u postgres

    After you are logged in to the postgres account, you can create a new user by the command:

    createuser --interactive

    This will prompt you with some choices and, based on your responses, execute the correct Postgres commands to create a user.

    Pass over a role name and some permissions and the role is created, you can then migrate your db

提交回复
热议问题