我正在尝试为我的数据库 (CLI) 中新创建的用户添加权限。但我收到一个错误,可能是因为我的数据库名称中有一个破折号,但你如何解决它?
错误:
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 '-acc.* TO 'bivv-acc'@'localhost'' at line 1
Run Code Online (Sandbox Code Playgroud)
实际命令:
GRANT ALL PRIVILEGES ON bivv-acc.* TO 'bivv-acc'@'localhost';
Run Code Online (Sandbox Code Playgroud)
注意:我是在我的数据库中,而不是在所有数据库的概览中。有什么线索吗?
干杯,
小智 5
尝试使用反引号来转义破折号,例如
GRANT ALL PRIVILEGES ON `bivv-acc`.* TO 'bivv-acc'@'localhost';
Run Code Online (Sandbox Code Playgroud)
检查手册说:
如果标识符包含特殊字符或者是保留字,则每次引用它时都必须用引号引起来。
...
标识符引号字符是反引号(“`”)