#591·mysql

ParseDSN doesn't support usernames containing colons

Author: s7v7nislandsCreated May 11, 2017Updated Oct 10, 2025
Labelsbugwontfix

Issue description

ParseDSN unspoport ":" in username

Example code

go

func main() {
	config := &mysql.Config{
		User:   "user:db",
		Passwd: "test",
		Net:    "tcp",
		Addr:   "127.0.0.1",
		DBName: "test",
	}

	s := config.FormatDSN()
	fmt.Printf("dsn: %s\n", s)

	config2, err := mysql.ParseDSN(s)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("user: %s, pass: %s\n", config2.User, config2.Passwd)

}