How to solve the problem with go + mysql?

Hello, the problem there is a problem with mysql.
Connect so
db, err := sql.Open("mysql", "user:mypasword@tcp(myip:3306)/db_name?tls=skip-verify&autocommit=true")

Use:
_ "github.com/go-sql-driver/mysql"
"database/sql"
Then
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)

in mysql table
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`)
);

The compiler does not swear, but when calling the function:

http: panic serving 91.240.84.39:37623: dial tcp 91.240.84.39:3306: getsockopt: connection refused

Please tell me how to solve this problem.
July 8th 19 at 15:51
2 answers
July 8th 19 at 15:53
Solution
Check that mysql is running and really listens to this port at this address. You have just failed to connect to database.
sudo netstat-ntlup | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1153/mysqld
In myconf
bind-address = 0.0.0.0
Don't understand what's wrong:( - Maybell commented on July 8th 19 at 15:56
: Firewall does not cut? A Telnet on this port the connection is? - sam_Blanda commented on July 8th 19 at 15:59
July 8th 19 at 15:55
The problem is not with go, mysql, and [self-censorship]... why are You here in this line error ignored?
db, _ := sql.Open
And in others too.
Oh, You're right, I messed up.
This is what I get:
http: panic serving myip:37623: dial tcp myip:3306: getsockopt: connection refused - Maybell commented on July 8th 19 at 15:58
: well one leg you have already shot himself, scoring on the error and came to the toaster with the questions "why I became badly run". Now we have to learn how to Google the error, which you have given, the answers will find a bunch. - sam_Blanda commented on July 8th 19 at 16:01

Find more questions by tags MySQLGo