Taco Steemers

A personal blog.

Dropping a MySQL database that gives errorno: 39

The problem

Error number 39 may occur when you want to drop a database in MySQL. Annoying, especially when in a hurry to restore a database.

mysql> drop database my_db;
ERROR 1010 (HY000): Error dropping database (can't rmdir './my_db', errno: 39)

Apparantly not all files can be removed by MySQL. We will remove them manually.

The solution

Go to the directory where the database files is stored and check if any files are still there:

On Debian:

$ ls /var/lib/mysql/my_db

There are! Remove the remaining files and perform the drop database command again. Now the database is fully removed and ready to restore.

On Mac OS the directory that contains the databases is: /usr/local/var/mysql/ .