What if my user name contains at sign '@' when use golang sql to connect mysql?

Viewed 492

Application needs a user whose name contains @ character, I found it seems that golang-sql will crash while name contains @ and password is empty, just like

sql.Open("mysql", "root@proxy@tcp(172.21.30.22:3306)..")
1 Answers

When you use special characters in your usernames you should use quotes to separate the username from the domain name

For example

sql.Open("mysql", "'root@proxy'@'tcp(172.21.30.22:3306)'")
Related