I've been trying to set up my new macbook pro (Sierra 10.12.5) for using Rails - I've installed Ruby 2.4.1, Rails 5.0.2 and PSQL 9.6.3. I was having trouble over installing pg 0.20.0, but I was able to do this through Homebrew.
我一直在尝试使用Rails设置我的新macbook pro(Sierra 10.12.5) - 我已经安装了Ruby 2.4.1,Rails 5.0.2和PSQL 9.6.3。我在安装pg 0.20.0时遇到了麻烦,但我能够通过Homebrew做到这一点。
Now I'm unable to run any of my MVCs through the local host as I'm told:
现在我告诉我,无法通过本地主机运行我的任何MVC:
PG Connection Bad - fe_sendauth: no password supplied -
# connected server's characteristics.
def connect
@connection = PGconn.connect(@connection_parameters)
configure_connection
rescue ::PG::Error => error
if error.message.include?("does not exist")
I assume this to be a problem with psql connecting to the server, but I'm really not sure what it could be or what to do next.
我认为这是psql连接到服务器的问题,但我真的不确定它可能是什么或下一步做什么。
I would really appreciate any pointers, thanks.
我非常感谢任何指针,谢谢。
1 个解决方案
#1
1
Make sure you have config/database.yml
present with the following content
确保config / database.yml具有以下内容
development:
adapter: postgresql
encoding: utf8
reconnect: false
database: development_db
pool: 5
username: postgres # Replace this with correct username
password: db_password # Replace this with correct password
host: localhost
You can make use of Environment Variables here
您可以在此处使用环境变量
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASS'] %>
You need to set it first in shell
你需要先在shell中设置它
$ export DB_USER=postgres
$ export DB_PASS=password
#1
1
Make sure you have config/database.yml
present with the following content
确保config / database.yml具有以下内容
development:
adapter: postgresql
encoding: utf8
reconnect: false
database: development_db
pool: 5
username: postgres # Replace this with correct username
password: db_password # Replace this with correct password
host: localhost
You can make use of Environment Variables here
您可以在此处使用环境变量
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASS'] %>
You need to set it first in shell
你需要先在shell中设置它
$ export DB_USER=postgres
$ export DB_PASS=password