I am trying to create a MySql user from a Golang program but I am unable to find the correct formatting of the SQL string:
_, err := db.Query("CREATE USER ?@`%` IDENTIFIED BY ?",username)
I have tried many variations: enclosing the ?
in backticks, single quotes, parenthesis, but nothing works.
I either get
sql: expected 0 arguments, got 1
(or 2 if I add one or two parameters), or I get
Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?@`%` IDENTIFIED BY ?' at line 1
I have found similar questions but none is using the CREATE USER, and none of the solutions found there worked for me. Thanks