GRANT ALL ON my-database.* TO [email protected] IDENTIFIED BY 'password';
ERROR 1046 (3D000): No database selected
好的,我创建了一个名称上带有“-”的数据库(对用户做了同样的事情)......然后当我尝试对其设置授权时,数据库将无法工作。
如果我使用基地,错误是不同的
MariaDB [(none)]> use my-base
Database changed
MariaDB [my-base]> GRANT ALL ON 'my-base'.* TO 'my-user'@'10.0.0.1' IDENTIFIED BY 'password';
ERROR 1064 (42000): 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 ''my-base'.* TO 'my-user'@'10.0.0.1' IDENTIFIED BY 'password'' at line 1
MariaDB [my-base]>
尝试用反引号转义它?
此外,如果您已经有一个用户
my-user
@10.0.0.1
,则不需要提供IDENTIFIED BY...
您的授权声明部分