Problem

I'm trying to connect to sql db but it is throwing the following error:
Command:
go run main.go
Output:
dial tcp 127.0.0.1:3306: connectex: No connection could be made because the target machine actively refused it.
exit status 1

Code Snippet:
db,err := sql.Open("mysql", "prxqamydb:dbnms#666@tcp(fcdb1198)/IPCC")
if err != nil {
fmt.Println(err)
}

e := db.Ping()
if e != nil {
	log.Fatal(e)
}else{
fmt.Println("Ping to database successful, connection is still alive")}


var vcCode string
 rows, err:= db.Query("SELECT vcCode FROM dbo.CodeMaster")
 if err!=nil{
 log.Fatal("Not working ")
 }else{
 fmt.Println("working")
 }
 defer rows.Close()
 
 for rows.Next(){
 err:=rows.Scan(&vcCode)
 if err != nil {
 log.Fatal("Not again")
 }
 fmt.Println(vcCode)
 }

N.B: I have imported both
"database/sql"
_ "github.com/go-sql-driver/mysql"

I do not know how to proceed from here.


Answer / Solved

for ubuntu

edit /etc/mysql/mysql.conf.d/mysqld.cnf
then comment these lines

#bind-address           = 127.0.0.1
#mysqlx-bind-address    = 127.0.0.1