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.
Go to the directory where the database files is stored and check if any files are still there:
$ ls /var/lib/mysql/my_db DATABASECHANGELOG.frm DATABASECHANGELOGLOCK.frm
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: