MySQL error while dropping databases
A few months back I was trying to drop some unnecessary test and archived databases from MySQL servers and while dropping a database I got the following error message.
mysql> drop database dw_test; ERROR 1010 (HY000): Error dropping database (can't rmdir './dw_test/', errno: 17)
First, I thought it was related to directory permissions ie. MySQL user's write permissions on the database directory were revoked by someone for some strange reason. I opened another SSH sessions on the same server and took a look into the MySQL data directory but strangely did not find any permission related issues and MySQL user had the right ownership and permissions on data directory. I was also thinking may be someone locked the directory file somehow but then I listed the contents of database directory dw_test/ and found out that there was a file inside dw_test/ directory. This was the file that usually gets created by our backup script containing the binary log coordinates of the server where the backup was taken from and because of the presence of the file MySQL was denied deletion of the folder and hence the database (although MySQL had successfully deleted all table and index files from the directory). Basically, this dw_test was a copy of some other database created by someone for testing purposes.
$ sudo rm /data1/mysql/data/dw_test/log.status
Then, I logged back in to MySQL cli and ran the following with success.
drop database dw_test; Query OK, 0 rows affected (0.08 sec)
Please feel free to use the comments form below if you have any questions or need more explanation on anything. Use the icons below to share this tutorial with your friends.