-1

I created a database named "default" in MySQL, but I am not able to drop it through 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

Also, I am not able to grant to a particular user I created with this database

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

What went wrong? Please give me some hints.

4

2 回答 2

1

default is a reserved keyword used for assigning default values to fields:

create table t (a int default 1);

avoid using reserved keywords as table names, but if you want to do so you should enclose the word in `s:

 drop database `default`;
于 2013-04-21T20:55:00.360 回答
0
drop database `default`;

Should do the trick. Same for grant.
Thru it is better to avoid usage of reserved keywords for naming your schemas/tables/columns etc.

于 2013-04-21T20:44:40.927 回答