I am trying to drop MySQL database but it's showing an error in console

时间:2016-09-01 06:17:31

标签: mysql

In console I am trying to drop database using command

drop database database_name;

But it's throwing the below error.

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 'database check' at line 1

I also tried to use another command:

mysqladmin -u root -p drop check;

It is throwing an error below

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 'mysqladmin -u root -p drop check' at line 1

How to fix it?

1 个答案:

答案 0 :(得分:4)

CHECK is a reserved word in MySQL, you should use back-tick character to escape it:

DROP DATABASE `check`;

In future, try to avoid using reserved words as names of tables/databases to prevent such things from happening.

相关问题