Answer the question
In order to leave comments, you need to log in
How to solve problem with go + mysql?
Hello, the problem is there is a problem with mysql.
I connect like this
db, err := sql.Open("mysql", "user:[email protected](myip:3306)/db_name?tls=skip-verify&autocommit=true")
stmt, err := db.Prepare("INSERT userinfo SET username=?,departname=?,created=?")
res, err := stmt.Exec("one", "two", "2012-12-09")
id, err := res.LastInsertId()
fmt.Println(id)
CREATE TABLE `userinfo` (
`uid` INT(10) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(64) NULL DEFAULT NULL,
`departname` VARCHAR(64) NULL DEFAULT NULL,
`created` DATE NULL DEFAULT NULL,
PRIMARY KEY (`uid`)
);
http: panic serving 91.240.84.39:37623: dial tcp 91.240.84.39:3306: getsockopt: connection refused
Answer the question
In order to leave comments, you need to log in
Check that mysql is running and is really listening on the given port at the given address. You just have an error connecting to the database.
The problem is not with go + mysql, but with [self-censorship] ... Why are you ignoring the error in this line?
Yes, and the rest too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question