不幸的是,我的数据库名称中有一个破折号。mysql 报告语法错误,我该如何授予该数据库的访问权限。
例如
GRANT SELECT,INSERT,UPDATE,DELETE ON astpp.* TO 'portal'@'localhost'
IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
有效,但是
GRANT SELECT,INSERT,UPDATE,DELETE ON astpp-eth01.* TO 'portal'@'localhost'
IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
才不是。
也不行:
GRANT SELECT,INSERT,UPDATE,DELETE ON 'astpp-eth01'.* TO 'portal'@'localhost'
IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
答案1
在 mysql 上,除非启用了 ANSI_QUOTES,否则可以使用反引号字符转义数据库列名称。请参阅http://dev.mysql.com/doc/refman/5.0/en/identifiers.html。
尝试使用这样的命令。
grant select,insert,update,delete on `astpp-eth01`.* to 'portal'@'localhost' identified by 'Ab7g12Xh35' with grant option;