Rails and PostgreSQL: Role postgres does not exist

前端 未结 13 2186
一整个雨季
一整个雨季 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条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 08:36

    I ended up here after attempting to follow Ryan Bate's tutorial on deploying to AWS EC2 with rubber. Here is what happened for me: We created a new app using "

    rails new blog -d postgresql

    Obviosuly this creates a new app with pg as the database, but the database was not made yet. With sqlite, you just run rake db:migrate, however with pg you need to create the pg database first. Ryan did not do this step. The command is rake db:create:all, then we can run rake db:migrate

    The second part is changing the database.yml file. The default for the username when the file is generated is 'appname'. However, chances are your role for postgresql admin is something different (at least it was for me). I changed it to my name (see above advice about creating a role name) and I was good to go.

    Hope this helps.

提交回复
热议问题