项目移植到另一台电脑后出现以下问题,及其解决方法:
package models
import (
"github.com/astaxie/beego/orm"
_ "github.com/go-sql-driver/mysql"
)
// user 用户表
type user struct {
id int
username string
password string
}
func init() {
orm.registerdatabase("default", "mysql", "root:root@tcp(127.0.0.1:3306)/test_beego?charset=utf8")
orm.registermodel(new(user))
orm.runsyncdb("default", false, true)
}
解决方法是 127.0.0.1换成localhost以后,就能成功运行并连接数据库了
如对本文有疑问, 点击进行留言回复!!
VSCode1.4 搭建Golang的开发调试环境(遇到很多问题)
网友评论