Openshift:无法使用本地主机连接到 mysql

Openshift: Unable to connect to mysql using localhost

尝试在 Openshift jboss/mysql 设备上部署我的应用程序。我的 hibernate.cfg.xml 包含 localhost/db_name 作为 hibernate.connection.url。我想维护它。但是休眠无法连接。如果我明确提到我在 my.cnf 中看到的 bind_address,它会按预期工作。

知道吗,如何将我的本地主机映射到该绑定地址?我无法在 Openshift 上编辑 my.cnf。

您应该使用 MySQL 环境变量,而不是 "localhost",因为您的 MySQL 实例未在本地主机上侦听。参考这两篇关于OpenShift环境变量的文章,一般来说mysql,它们应该可以帮助你得到你的应用运行.

https://developers.openshift.com/en/managing-environment-variables.html https://developers.openshift.com/en/databases-mysql.html