Rails 应用程序无法连接到 PostgreSQL
我来自 PHP/MySQL 世界,尝试建立一个 Rails/PostgreSQL 应用程序。它似乎不想连接,我很难确定问题的原因。我可以采取某些故障排除步骤来找出问题所在吗?
更新:问题不在于 PostgreSQL。我可以通过命令行、通过 IDE 远程连接以及通过 PHP 脚本连接到 PostgreSQL。我似乎无法通过这个 Rails 应用程序连接到它。
I'm coming from the PHP/MySQL world, trying to set up a Rails/PostgreSQL app. It doesn't seem to want to connect and I'm having a hard time pinning down the cause of the problem. Are there certain troubleshooting steps I can take to figure out what's going wrong?
Update: the problem is not with PostgreSQL. I can connect to PostgreSQL via the command line, remotely via an IDE, and via a PHP script. I just can't seem to connect to it through this Rails app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我将从实际的database.yml 文件开始,以确保我拥有所有正确的用户和密码信息。
我还要确保我运行了您所做的任何事情来使 postgres 启动它的服务器,以便可以建立连接。 (无论您使用
psql start
还是在您启动开发环境时启动。所以只有您可以回答这个问题)。数据库创建了吗?
我可以通过控制台连接吗?
rails console
不应给出错误。您是否安装了正确的 postgres gem,并且它位于您的捆绑文件(或environment.rb 文件)中?
First I'd start with the actual database.yml file to make sure i have all the right user and password information.
I'd also make sure i ran whatever it is you do to make postgres start it's server, so that connections can be established. (Whether you use a
psql start
or it starts when you start your dev env. So only you can answer that one).Is the database created?
Can i connect through console?
rails console
shouldn't give an error.Do you have the correct postgres gem installed and is that in your bundle file (or environment.rb file)?