The following problems after transplant project to another computer, and their solutions:
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) }
The solution is to be replaced after 127.0.0.1 localhost, and will be able to successfully run the database connection