玩!框架 - 无法连接到数据库 [英] Play! framework - Cannot connect to database

查看:220
本文介绍了玩!框架 - 无法连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在尝试连接到本地postgresql db时获得的错误:

this is the error I get when I'm trying to connect to my local postgresql db:


无法连接到数据库[default ]

Cannot connect to database [default]

这是数据库配置。 我确信没有错字(胖手指错误)

db.default.url="postgres://localhost:5432/myproject/"
db.default.user="postgres"
db.default.pass="mypassword"
db.default.driver="org.postgresql.Driver"
db.default.initSQL="SELECT 1" 

哪里有问题? 与pgAdmin我可以轻松连接

p.s.

我使用的是ubuntu。我注意到为了改变为postgres用户

我必须使用su,否则它会改变当前用户。

是有关的游戏!连接我的db失败?

where is the problem? with pgAdmin I can connect easily
p.s.
I'm using ubuntu. I've noticed that in order to change to postgres user
I must use "su", otherwise it fails changing the current user.
is that has something to do with play! failure to connect my db?

感谢

推荐答案

首先: postgres:... URL语法不是普通的JDBC URL。 PostgreSQL JDBC驱动程序不能理解这种格式。请参见此答案以解决类似问题。

First: The postgres:... URL syntax is not a plain JDBC URL. This format is not understood by the PostgreSQL JDBC driver. See this answer to a similar problem.

第二:您正在尝试使用PostgreSQL超级用户帐户。超级用户帐户应仅对用于管理工作,而不是正常工作。 不适用于通过某些webfrontend公开访问数据库的工作。任何SQL注入攻击给攻击者的数据库的金钥匙 - 包括nuke立即破坏您的完整的数据库群集或安装任何后门到您的数据库服务器。

Second: You are trying to use the PostgreSQL superuser account for Play. The superuser account should be used only for administrative work, but not "normal" work. Especially not for work which includes public access to the DB via some webfrontend. Any SQL-Injection attack gives the attacker the golden key to your database - including the nuke to wreck your complete DB cluster at once or install any backdoor into you DB server.

所以我建议你创建一个新的用户,你在你的Play配置!设置。

So I recommand, that you create a new user which you configure in your Play! settings.

也就是说: postgres 用户的默认密码不是在Ubuntu上。此设置仅允许从同一个 OS用户登录 DB用户。如何解决此问题,请参阅此答案

That said: The default password for the postgres user is not set on Ubuntu. This setup allows login to the DB user only from the same OS user. How you can fix this is explained in this answer.

如果这两个提示没有帮助:您引用的错误非常模糊。必须 更详细的错误日志 。请找到它们,并通过编辑按钮将它们附加到您的问题。

If these two tips don't help: The error you quoted is very vague. There must be more detailed error logs somewhere. Please find them and attach them to your question with the "edit" button.

这篇关于玩!框架 - 无法连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆