I want to connect to the database of the site 000webhost.com , id00000_admin:Password123@mydb-night.000webhost.com/id00000_db_name .

Hosting http://mydb-night.000webhost.com/ (Figuratively speaking) , tried and shoved his host. Writes: panic: default addr for network 'mydb-night.000webhost.com' unknown

All data is correct, here is the table on the site itself:

 DB Name DB User DB Host id00000_db_name id00000_admin localhost 

I tried localhost, databases-auth.000webhost.com, mydb-night.00webhost.com .

config.yml:

 MYSQL: data: id00000_admin:Password123@mydb-night.000webhost.com/id00000_db_name 

Code:

 var Config = struct { Mysql struct { Data string `yaml:data` Columns string `yaml:columns` } `yaml:"MYSQL"` }{} configor.Load(&Config, "config.yml") var db *sql.DB db, err = sql.Open("mysql", Config.Mysql.LoginData) if err != nil { panic(err) fmt.Println(err) fmt.Println("err connect to db") } else { fmt.Println("succ connect to db") } defer db.Close() err = db.Ping() if err != nil { panic(err) fmt.Println(err) fmt.Println("err connect to db") } else { fmt.Println("succ ping to db") } ptable, err := db.Exec("CREATE TABLE minix ( db_int varchar(25), prep_id varchar(25), prep_user text, prep_mpt text, prep_gbt text)") if err != nil { panic(err) /*panic err call*/ fmt.Println(err) fmt.Fprintf("err connect to db") } else { fmt.Println("succ connect to db") } stmt, err := db.Prepare("INSERT INTO minix values (?, ?, ?, ?, ?)") if err != nil { panic(err) fmt.Println(err) fmt.Println("err prepare value") } else { fmt.Println("succ prepare value") } main_rows, err := stmt.Exec("152", "good", "adam", "love", "throw") if err != nil { panic(err) fmt.Println(err) fmt.Println("fmt err") } else { fmt.Println("succ insert") } 

Everything is exactly the error: panic: dial tcp 127.0.0.1:3306: connectex: No connection could be made because the target machine actively refused it. or panic: default addr for network 'databases-auth.000webhost.com' unknown . I can not host address to connect to the database.

  • show the code, without a code is difficult to judge. - biosckon
  • @biosckon changed. - massive
  • try to wrap the URL in DSN those in the id00000_admin:Password123@tcp(mydb-night.000webhost.com)/id00000_db_name file id00000_admin:Password123@tcp(mydb-night.000webhost.com)/id00000_db_name - biosckon
  • probably still need to specify the correct port and make sure that remote connect works on this service at all, if it complains that getsockopt: operation timed out then the port is probably incorrectly specified - biosckon
  • if you do not have a Premium hosting account, then remote access to mysql is disabled - biosckon

0