douniwan_0025 2017-04-22 17:06
浏览 63
已采纳

网络未知的Heroku cleardb连接默认地址

I have created a free instance of Heroku cleardb instance for my app. I set the database URL as:

heroku config:set DATABASE_URL='mysql://user:pass@us-cdbr-iron-east-03.cleardb.net/heroku_database?reconnect=true'

I'm trying to connect using a Go app. But when I try to access my application, it gives the following mysql error:

default addr for network 'us-cdbr-iron-east-03.cleardb.net' unknown

I tried to set the database url with protocol and port as well:

heroku config:set DATABASE_URL='mysql://user:pass@tcp(us-cdbr-iron-east-03.cleardb.net:3306)/heroku__database?reconnect=true'

This changes the errror to:

Access denied for user

which i'm guessing is because direct access to port is disallowed. Does anybody know what is the issue here?

  • 写回答

1条回答 默认 最新

  • dongque8332 2017-04-22 22:45
    关注

    This is a Go specific problem. Three changes are required:

    1. Go's sql.Open already takes scheme as its first parameter so it needs to be stripped off of DATABASE_URL.
    2. Connection string shouldn't have any query parameters (remove ?reconnect=true).
    3. Protocol (tcp) and port (3306 for MySQL) number are required.

    Thus final database URL would be:

    DATABASE_URL='user:pass@tcp(us-cdbr-iron-east-03.cleardb.net:3306)/your_heroku_database'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序