Help us understand the problem. What is going on with this article?

Ruby on RailsのデータベースをPostgreSQLに設定する。

ググッた情報でやっても
rake db:create
FATAL: Ident authentication failed for user "username"
がでてうまくいかなかったのでメモ

環境

Amazon-EC2
CentOS
Rails 4.2.4

やったこと

PostgreSQLのインストール

$ sudo yum -y install postgresql94
$ sudo yum -y install postgresql94-devel
$ sudo yum -y install postgresql94-server
$ psql --version
psql (9.4.5)

初期化からの起動

$ sudo /etc/init.d/postgresql94 initdb
$ sudo /etc/init.d/postgresql94 start

PostgreSQLアカウントの設定

$ sudo -u postgres psql
postgres=# alter role postgres with password 'hogehoge';
postgres=# alter role [user_name] with password '[password]';

データベースの作成

postgres=# create database [database_name] owner [user_name];

アクセス権限の設定

$ vim /var/lib/pgsql94/data/pg_hba.conf

local all all peer
local all all md5に変更

Railの設定

アプリの作成

$ rails new myapp -d postgresql

config/database.ymlの設定

default: &default
  adapter: postgresql
  encoding: utf8
  pool: 5
  username: [username]
  password: [password] 

development:
  <<: *default
  database: myapp_development

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  database: myapp_production

データベース作成

rake db:create

以上の手順で出来たんですが、これであっているのか分からないので何か気づいたらコメントお願いします。

Morinikiz
好きな言葉は激熱です
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした