不幸的是,我有一个带有破折号的数据库名称.
当 mysql报告语法错误时,如何授予对该数据库的访问权限.
当 mysql报告语法错误时,如何授予对该数据库的访问权限.
例如
GRANT SELECT,INSERT,UPDATE,DELETE ON astpp.* TO 'portal'@'localhost' IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
工作,但
GRANT SELECT,DELETE ON astpp-eth01.* TO 'portal'@'localhost' IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
才不是.
也不是:
GRANT SELECT,DELETE ON 'astpp-eth01'.* TO 'portal'@'localhost' IDENTIFIED BY 'Ab7g12Xh35' WITH GRANT OPTION;
解决方法
在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;