Это действительно меня застряло, я немного нуб, пытающийся использовать postgres для рельсов 4
У меня установлен постгрес:
$ psql --version
psql (PostgreSQL) 9.1.10
contains support for command-line editing
$ sudo apt-get install libpq-dev
работал нормально
У меня есть gem 'pg'
в моем gemfile
Мой config/database.yml
выглядит так:
development:
adapter: postgresql
encoding: unicode
database: myafricastyle_development
host: localhost
pool: 5
username: myafricastyle
password: myafricastyle
Создайте базу данных: $ sudo -u postgres createdb myafricastyle_development
Вот базы данных:
$ psql
psql (9.1.10)
Type "help" for help.
jasonshark=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------------+------------+----------+-------------+-------------+-----------------------
jasonshark | jasonshark | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
myafricastyle_development | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
Но затем, когда я пытаюсь настроить его в каталоге проекта rails, я получаю следующее:
$ rake db:create:all
FATAL: password authentication failed for user "myafricastyle"
FATAL: password authentication failed for user "myafricastyle"
Редактировать: Это мой файл pg_hba.conf
:
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres md5
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
Хотя, когда я редактировал, я сделал sudo gedit pg_hba.conf
, так что папка выглядит довольно прикольно:
/etc/postgresql/9.1/main$ ls
environment pg_hba.conf pg_ident.conf start.conf
pg_ctl.conf pg_hba.conf~ postgresql.conf
Что я могу изменить?