无法设置 rails 数据库

Unable to setup rails database

我正在尝试设置我的 rails 环境以在 CentOS7 上进行开发。当我尝试创建数据库时出现错误

PG::ConnectionBad: FATAL: no pg_hba.conf entry for host "[local]", user "antarr", database "postgres", SSL off。以下是我的配置

/var/lib/pgsql/10/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             postgres                                trust
# IPv4 local connections:
host    all            all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident

hostnossl all           all             0.0.0.0/0               trust
host    all             all             0.0.0.0/0               md5

postgresql.conf

listen_addresses = '*'

你可以看到在本地类型中你有用户权限 postgres 将其更改为 all 这样 antarr 用户可以连接到您的数据库或在您的 database.yml 中将 username 设置为 postgres

有关详细信息,请参阅 HERE