Why I don’t want to connect to the mysql server (located on the local host: Denwer ). Apache has the following configurations: $&{ip:-127.0.0.1}:$&{port:-80} . Mistake:
[mysql] 2017/11/29 20:56:50 packets.go:36: unexpected EOF panic: invalid connection Code:
package main import ( "database/sql" _ "github.com/go-sql-driver/mysql" ) func main() { ModuleCreateDatabase() } func ModuleCreateDatabase() *sql.DB { name := "testx" db, err := sql.Open("mysql", "root:echo123@tcp(127.0.0.1:80)/test") if err != nil { panic(err) } defer db.Close() eerr = db.Ping() if eerr != nil { panic(eerr.Error()) } _,err = db.Exec("CREATE DATABASE IF NOT EXISTS "+name) if err != nil { panic(err) } db.Close() return db } Bd is, the table is there, everything is there, the localhost works at the address that is registered in Apache . The password is correct: echo123 .
Openyou should always doPing. What will he get out? - Ainar-GOpenor an error fromPingwill tell you what's wrong. - Ainar-G