0

I recently installed Ubuntu and PostgreSQL. I'm trying to pull up my PostgreSQL database. If I type rails db I get this error

psql: FATAL: database "homed_in_development" does not exist

So I then try running rake db:create or rake db:migrate but I get the error

PG::InsufficientPrivilege: ERROR: permission denied to create database

So I have tried CREATE ROLE myusername; after getting into PostgreSQL through the common psql postgres, which gives me the error ERROR: permission denied to create role. I tried to fix this issue using ALTER USER myusername WITH SUPERUSER, but I got the error message ERROR: must be superuser to alter superusers

I also got the error FATAL: role “myusername” does not exist on something else, and so I think my issues are that I haven't got roles or permissions set up properly.

benRollag
  • 1,219
  • 4
  • 16
  • 21
maudulus
  • 10,627
  • 10
  • 78
  • 117
  • I typed in `SELECT current_user;` to check what my current username is and it is the username that it says does not exist (`Role...myusername does not exist...`) – maudulus May 13 '14 at 22:38
  • 1
    is this the first project you are using postgres? do you have previous project that you used `pg` in this machine? – Wally Ali May 13 '14 at 22:49
  • @WaliAli I made the project on another machine and am now using this new machine. – maudulus May 13 '14 at 22:55
  • 1
    see if [this](http://stackoverflow.com/questions/18289366/postgres-no-permission-to-create-user) helps you – Wally Ali May 13 '14 at 22:58
  • I was able to change the user's roles by first switching to the postgres user using `sudo -u postgres psql postgres` and then changing my other user under the postgres user using `ALTER USER maudulus WITH SUPERUSER;` – maudulus May 13 '14 at 23:01
  • 1
    So it worked? good work! – Wally Ali May 13 '14 at 23:07
  • @maudulus: You don't need sudo for that. You can `psql -U postgres...`. You might need other command-line options; you might need to type in the password for the user "postgres". – Mike Sherrill 'Cat Recall' Jul 04 '14 at 22:29

0 Answers0