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 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题