英文:
What if my user name contains at sign '@' when use golang sql to connect mysql?
问题
应用程序需要一个用户名包含@
字符的用户,我发现当用户名包含@
且密码为空时,golang-sql会崩溃,就像下面这样:
sql.Open("mysql", "root@proxy@tcp(172.21.30.22:3306)..")
英文:
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
得分: 1
当您在用户名中使用特殊字符时,应使用引号将用户名与域名分隔开。
例如:
sql.Open("mysql", "'root@proxy'@'tcp(172.21.30.22:3306)'")
英文:
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)'")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论