简体   繁体   中英

Rails app Postgres role doesn't exist

I looked rails screencast and I have done:

brew install postgresql

initdb /usr/local/var/postgres

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

rails new ispiti_postgres -d postgresql

bundle install

I started the server and I got this error:

Read error: ActiveRecord::NoDatabaseError: FATAL: role "darko" does not exist

Then I tried this:

darko@darko-Lenovo-G570 ~/Documents/pokusi/ispiti_postgres $ bundle exec rake db:create:all
FATAL:  role "darko" does not exist
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"ispiti_postgres_development"}
rake aborted!

I tried changing username in database.yaml in postgres , darko , root and subsequently command rails db but every time I got for example:

darko@darko-Lenovo-G570 ~/Documents/pokusi/ispiti_postgres $ rails db

psql: FATAL: role "root" does not exist

I tried with no username and still I got message that role darko doesn't exist.

I don't know how to access postgres . I try this:

darko@darko-Lenovo-G570 ~/Documents/pokusi/ispiti_postgres $ sudo -u postgres -i

[sudo] password for darko: 

postgres@darko-Lenovo-G570 ~ $ psql

psql: FATAL:  role "postgres" does not exist

Thanks

I am using Linux 32-bit and LinuxBrew can be installed only on 64-bit system. So brew command wasn't working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM