RT
按着官方文档,当连接一个已有的数据库时报
```
register db Ping `default`, default addr for network '123.56.93.183' unknown
must have one register DataBase alias named `default
```
代码如下
```
package main
import (
_ "beetest/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
)
func init() {
orm.RegisterDriver("mysql", orm.DRMySQL)
orm.RegisterDataBase("default", "mysql", "root:xxxxx@123.56.95.183/qianbao_test?charset=utf8")
}
func main() {
orm.Debug = true
o := orm.NewOrm()
o.Using("qianbao_test")
beego.Run()
}
```
有疑问加站长微信联系(非本文作者)