50

Consider:

DROP DATABASE db_name;
ERROR 1010 (HY000): Error dropping database (can't rmdir './db_name', errno: 66)

The problem is that I don't know where the file/directory is located - this file is missing in /usr/local/mysql/bin/...

How do I fix this issue?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user984621
  • 46,344
  • 73
  • 224
  • 412
  • 1
    `datadir=` in my.cnf should point you to your data directory. – MrCleanX May 13 '13 at 16:48
  • I just want to point out that happened to me in phpmyadmin with case-sensitive database name, for example if I try to drop `my_DATAbase` I can see that error. The folder name is `my_DATAbase` but phpmyadmin is trying to delete the folder `my_database`. – peppeocchi Jun 17 '15 at 09:36

3 Answers3

110
mysql> drop database DB_NAME; 
ERROR 1010 (HY000): Error dropping database 
(can't rmdir './DB_NAME', errno: 66)
  1. Find the database directory: mysql -e "select @@datadir" -> /usr/local/mysql/data/

  2. Go to the DataBase folder: cd /usr/local/mysql/data/

  3. Delete DB folder of the DB with the issue (in this case: sudo rm -rf DB_NAME)

Hackerman
  • 12,139
  • 2
  • 34
  • 45
  • Hello, the first point - I get only `/usr/local/bin/mysql`, `cd /usr/local/bin/mysql` => `Not a directory` – user984621 May 13 '13 at 16:57
  • You have your mysql in a different directory...then check datadir= in my.cnf should point you to your data directory – Hackerman May 13 '13 at 16:59
  • How can I display it? Where is it located? – user984621 May 13 '13 at 17:22
  • Here are possible locations of the my.cnf file for version 5.5 on Mac OS X: /etc/my.cnf /etc/mysql/my.cnf SYSCONFDIR/my.cnf $MYSQL_HOME/my.cnf defaults-extra-file (the file specified with --defaults-extra-file=path, if any) ~/.my.cnf – Hackerman May 13 '13 at 17:32
  • Just incase you face issue deleting the folder because of permission issues you may do that as an admin/root user. It worked for me. Thanks Robert – Yoosaf Abdulla Jun 26 '13 at 10:25
  • 3
    mysql -e "select @@datadir" – Josh Unger Jul 08 '13 at 16:04
  • 2
    In my case i'm running in local AMPPS and i have the same problem. The only way to fix it was to manually delete the database folder in /Applications/AMPPS/var/ "the-folder-nameo-db" – marcoqf73 Feb 01 '14 at 23:38
  • 3
    Type: mysql -e "select @@datadir" This will show you where your database(s) exist. Goto that folder shown from the command above. Delete the corrupted db by typing: rm -rf yourDbName Thank you @Robert Rozas – Tyler Rafferty Jul 29 '14 at 18:16
  • If you get an access denied error, you have to execute this command as a root user (or an user with root access): `mysql -u root -p -e "select @@datadir"` you will be asked for your password, after that the datadir will show up. – Peter Jul 03 '16 at 13:48
  • On OSX, my database folders are in my database directory, i.e. `/usr/local/var/mysql/ ` not in a `data` subdirectory. Deleting these solved my issue. – Janac Meena May 05 '20 at 15:25
4

If you are using XAMPP in OSX the data directory would be at

/Applications/XAMPP/xamppfiles/var/mysql
kbokdia
  • 439
  • 5
  • 11
0

FYI for mac users with normal mysql server:

/usr/local/mysql/bin/mysql -u root -pPASSWORD  -e "select @@datadir"
Bjørson Bjørson
  • 1,583
  • 1
  • 17
  • 31