dsjmrpym220113739 2018-10-15 00:57
浏览 124
已采纳

Beego ORM MySQL:网络“ ...”的默认地址

My database link is a domain name instead of an IP address, and I don't use the ip address. Below is my configuration.

orm.RegisterDataBase("default", "mysql", "root:root@*******.aliyuncs.com:3308/dbname?charset=utf8")

Error Message:

register db Ping default, default addr for network '***.mysql.rds.aliyuncs.com:3308' unknown must have one register DataBase alias named default

  • 写回答

1条回答 默认 最新

  • douhan8610 2018-10-15 01:41
    关注

    I checked on the go-mysql-driver source code, on file dsn.go:86, the error only occurred when the network type is "".

    You need to specify the selected network type on the connection string (whether it is tcp or unix). Use below connection string scheme instead of the one you are currently used.

    <username>:<password>@<network-type>(<host>:<port>)/<dbname>
    

    With your code, it would be like this:

    connectionString := "root:root@tcp(*******.aliyuncs.com:3308)/dbname"
    orm.RegisterDataBase("default", "mysql", connectionString)
    

    Note: network type tcp is chosen in example above.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog