Postgres permission denied to create database on rake db:create:all

后端 未结 2 2007
北恋
北恋 2020-12-05 00:11

I am trying to create postgres databases for development and tests.

I\'m using...

  • OSX Yosemite
  • Rails version: 4.2.0
  • git version: 2.2
相关标签:
2条回答
  • 2020-12-05 00:35

    Looking at your schema your credentials for development and test are different.

    Perhaps remove username and password from the schema, seeing that your test database did get created.

    0 讨论(0)
  • 2020-12-05 00:40

    I have faced same issues when running rake db:test:prepare in postgresql on my Ruby on Rails project. This is pretty clear from the error message, that its a permission issue for the user. I added CREATEDB permission for new_user as following from the console.

    To access postgres console:

    $ sudo -u postgres -i
    
    postgres@host:~$ psql
    

    In there:

    postgres=# ALTER USER new_user CREATEDB;
    

    It's working perfect for now. You may have another issues with database ownership, for this you can change database privileges and owner as following command.

    postgres=# GRANT ALL PRIVILEGES ON  DATABASE database_name to new_user;
    postgres=# ALTER DATABASE database_name owner to new_user;
    
    0 讨论(0)
提交回复
热议问题