I've been having an issue with this for a few weeks now but hasn't focued on this since rails isn't my focus.
Can someone help me?
Ever since I installed pgAdmin 4, I've been getting issues with Rails projects. Just like this one:
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Couldn't create 'db_name' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: permission denied for database "postgres"
DETAIL: User does
…
Top comments (17)
I answer your question at there.
This is the good url for learn about your problem: stackoverflow.com/questions/391692...
Btw, my suggestion, you can try to connect to database first from postgresql client. to make sure your permission is already right
Hey Andre thanks for your time. I actually saw this earlier and did the commands but
rails db:setup
threw the error on the SO question. But when I ranrails db:migrate
it generated ashema.rb
on thedb
folder with data on it even if I haven't written any schemas.help.heroku.com/63D7ALXT/why-am-i-...
Try to read from there, this is the answer:
I actually did
rails db:migrate
but the schema looked like it came from one of my old Django projectshmmm.. I think you still misunderstood the answer above.
So I think the problem you have, lies in
rails db:setup
because of those commands needs permission to create/drop the database which is it needs more authorization than just privileges for doing anything in one database.all this time, you just give all privileges to one database like you mention it on your question at SO.
Those command just give authorization to user_name for have all_privileges and connect to one database which is db_name.
But,
rails db:setup
need permission beyond that. those command need to create/drop database(like db_name not just permission to access) which still not provide from the command you give it to the user_name.So my suggestion to you,
You can add permission to create database also to your DB user(user_name).
Or try to find other command from rails like db:schema:load, db:structure:load, db:migrate which can fulfill your needs without give more permission to your user.
Thanks for that detailed reply. I did this:
Then it spit out
I don't know what to do anymore.
Hmm.. I see..
You still have option.
How about altering as superuser?
I did that.
highcenoid is my superuser.
Are there any other options?
can you check all your user permission? use this command
post it here.
Here it is
hahaha.. such strange error!
Hmmm.. if you running other command like
rails db:create
andrails db:migrate
. is that running well too?and can you copy your database.yml also to here? (just delete the password part or it's not possible, just confirm all the value is right)
I know!!!
rails db:migrate
actually does it's job and I thinkrails db:create
too. It's just therails db:setup
that messes up our brains.Wait, so I need to include my user password on the
database.yml
file?Hmmm..
Check it here:
digitalocean.com/community/tutoria...
At those post, They give an example minimal database.yml that can be running for rail apps:
I haven't tried to fix the
database.yml
but I think this will fix it. Thanks Andre! Will let you know if the problem would still be persistent.I think my psql's f*cked up. Would uninstalling & reinstalling it fix the issue?
Maybe. That's why my next suggestion is to try connect first with db client like pgadmin, etc from your laptop. To see if your db(postgre) actually works or not.
After that it's 90% permission issue. Something(Permission) need you give to the user.
Thanks Andre