MySQL error: error 1010 (HY000) when deleting database

mysql> drop database testdb;

ERROR 1010 (HY000): Error dropping database (can’t rmdir ‘./testdb/’, errno: 17)

mysql> select @@datadir;


| @ @ datadir |


| /usr/local/mysql/data/ |


1 row in set (0.00 SEC)
The reason is that there are files other than database files in the directory of data /usr/local/mysql/data/. You can CD to its directory after clearing it out. Drop again
[root-@localhost104 testdb]# CD testdb
[root-@localhost104 testdb]# ll
total 0
-rw-r — r-1 root root 0 Jul 23 10:22 delete.txt
[root-@localhost104 testdb]# rm delete.txt
rm: Remove regular empty File ‘delete.txt’?yes
mysql> drop database testdb;
Query OK, 0 rows affected (0.06 SEC)
The database directory cannot hold files unrelated to the database!

Read More: