Skip to content

Instantly share code, notes, and snippets.

@radinreth
Created October 12, 2017 16:28
Show Gist options
  • Select an option

  • Save radinreth/f034b994259f00b2194fc7ccf135faf8 to your computer and use it in GitHub Desktop.

Select an option

Save radinreth/f034b994259f00b2194fc7ccf135faf8 to your computer and use it in GitHub Desktop.

Revisions

  1. radinreth created this gist Oct 12, 2017.
    21 changes: 21 additions & 0 deletions Cannot run rake db:reset
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # https://stackoverflow.com/questions/28116927/postgres-permission-denied-to-create-database-on-rake-dbcreateall
    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;

    then
    sudo service postgresql restart

    then
    rake db:reset