我在MySQL中创建了一个名为“default”的数据库,但是我无法通过MySQL shell删除它:
mysql> drop database default;
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 'default' at line 1
另外,我无法授予我使用此数据库创建的特定用户
mysql> grant all on default.* to 'myuser'@'localhost';
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 'default.* to 'myuser'@'localhost'' at line 1
出了什么问题?请给我一些提示。
答案 0 :(得分:1)
default
是一个保留关键字,用于为字段分配默认值:
create table t (a int default 1);
避免使用保留关键字作为表名,但如果您想这样做,则应将该单词括在`
s中:
drop database `default`;
答案 1 :(得分:0)
drop database `default`;
应该做的伎俩。同样的补助金。
通过最好避免使用保留关键字来命名你的模式/表/列等。