我可以使用 Rails 连接到服务器的 postgres,但无法通过命令行连接
I can connect to server's postgres with Rails, but am unable to through the command line
我正在尝试通过脚本连接到服务器的 Postgres 数据库。我已经通过 ssh 进入了盒子并尝试了
$ psql postgres -U my_username -W #And then entered the password
并得到错误:
psql: FATAL: Peer authentication failed for user "my_username"
但是,此服务器上的 Rails 应用程序 运行 正在使用这些相同的凭据。我在 rails 控制台中使用了 ActiveRecord::Base.connection_config
,并且使用了与尝试使用 psql
时完全相同的凭据。在 rails 控制台中,我可以查询数据库,所以我知道连接在那里工作。
是否有可能某处存在限制,阻止我通过 psql
进行连接?还是我做错了什么?
你试过这样吗:
psql --username="postgres"
另一种可能是通知更多参数
psql --username="postgres" --host="<ip or host name>" --port="<port, default 5432>" -W <db name>
好看!
尝试这样连接:
psql postgres -U my_username -h 127.0.0.1 -W #And then entered the password
我正在尝试通过脚本连接到服务器的 Postgres 数据库。我已经通过 ssh 进入了盒子并尝试了
$ psql postgres -U my_username -W #And then entered the password
并得到错误:
psql: FATAL: Peer authentication failed for user "my_username"
但是,此服务器上的 Rails 应用程序 运行 正在使用这些相同的凭据。我在 rails 控制台中使用了 ActiveRecord::Base.connection_config
,并且使用了与尝试使用 psql
时完全相同的凭据。在 rails 控制台中,我可以查询数据库,所以我知道连接在那里工作。
是否有可能某处存在限制,阻止我通过 psql
进行连接?还是我做错了什么?
你试过这样吗:
psql --username="postgres"
另一种可能是通知更多参数
psql --username="postgres" --host="<ip or host name>" --port="<port, default 5432>" -W <db name>
好看!
尝试这样连接:
psql postgres -U my_username -h 127.0.0.1 -W #And then entered the password