Bug #114605 MySQL drop database with the name 'database'
Submitted: 10 Apr 2024 8:05 Modified: 10 Apr 2024 13:15
Reporter: Siddharth Deo Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Utilities Severity:S3 (Non-critical)
Version:8.3.0 OS:Ubuntu
Assigned to: CPU Architecture:Any

[10 Apr 2024 8:05] Siddharth Deo
Description:
The issue has been filed to report the ambiguous behavior of mysql utilities - mysqladmin & mysql client on the command line while dropping a database named 'database'. The database 'database' was created with the mysqladmin utility and the ambiguity was noticed while dropping the database.

 

How to repeat:
Step 1: Create the database with the name 'database' using the mysqladmin utility

$ mysqladmin -u root Create database

Step 2: Login to the mysql server using the client and check with 'show databases'. The database 'database' has been created.

$ mysql -u root -p

mysql> show databases;

Step 3: Issue 'drop database' from the mysql prompt 

mysql> drop database database;

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

Step 4: Exit from the mysql prompt and return to the unix shell

mysql> exit

Step 5: On the unix shell drop the database 'database' using mysqladmin 

$ mysqladmin -u root drop database

Step 6: Login again using mysql client and check with 'show databases'

$ mysql -u root -p

mysql> show databases;
[10 Apr 2024 13:15] MySQL Verification Team
Hello Siddharth,

Thank you for the bug report.
Imho this is not a bug, 'Database' is a reserved word and it cannot be used in standard SQL. Please check the doc available at https://dev.mysql.com/doc/refman/8.0/en/keywords.html

However, if you still need to use it, try in `backticks`!

Regards,
Ashwini Patil