简体   繁体   中英

learning postgresql: downloaded it, set it up, trying to connect to it in rails but failing -username,password

Im trying to use rails with postgresql and I set everything up properly with the download and gems.

I generated a new rails project with postgresql using this command:

rails new demo_app -d postgresql
rake db:create all

Here is my databse.yml file contents:

development:
adapter: postgresql
encoding: unicode
database: demo_app_development
pool: 5
username: 
password: guess_password

this didnt work: got the following error

AM @~/Documents/RailsWS/demo_app >rake db:create:all
FATAL:  password authentication failed for user "AM"

So the issue is the user name and password combination. However, I dont remember what I put in when I downloaded and set up postegresql. Is there anyway I can reset the username and password and start from scratch with a new username and password?

Thanks

我在postgres的Rails设置中遇到了麻烦,这个railscast帮助了我。

After installation you can run the following in the terminal:

createuser -P

(The -P is to add a password)

It will ask you for name, password, whether they are a superuser, can create new roles, and can create new db's. You probably won't need any of those permissions for rails.

Then create the database to run with the following role you created:

createdb -O ROLE_NAME_FROM_PREVIOUS_STEP NEW_DATABASE_NAME

And viola, you should be good to go.

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