-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.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Qiang Li
  • 10,593
  • 21
  • 77
  • 148

2 Answers2

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`;
jurgenreza
  • 5,856
  • 2
  • 25
  • 37
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.

alexrider
  • 4,449
  • 1
  • 17
  • 27