3

I was receiving this error when trying to drop a database:

ERROR 1010 (HY000): Error dropping database (can't rmdir './redpopdigital@002ecom', errno: 39 "Directory not empty")

So I went into /var/lib/mysql and just did an rm -rf. I did not know that this would screw with literally every other database.

Now it seems all of my databases are inaccessible.

I tried this as a troubleshooting step:

ubuntu@blainelafreniere:~$ mysqlcheck --repair blainelafreniere -u root -p
Enter password: 
blainelafreniere.wp_commentmeta
Error    : Table 'blainelafreniere.wp_commentmeta' doesn't exist in engine
status   : Operation failed
blainelafreniere.wp_comments
Error    : Table 'blainelafreniere.wp_comments' doesn't exist in engine
status   : Operation failed
blainelafreniere.wp_links
Error    : Table 'blainelafreniere.wp_links' doesn't exist in engine
status   : Operation failed

what's weird is, all of the data appears to be chilling in /var/lib/mysql... but I can't access it for some reason?

Is there any hope of recovering the data from /var/lib/mysql or am I completely screwed?

Thanks.

2 Answers2

4

I went into /var/lib/mysql and just did an rm -rf. I did not know that this would screw with literally every other database.

Oh dear.

Your machine was trying to prevent you from deleting something - but you forced it to anyway?
The thing it was trying to protect was inside your MySQL installation - and that didn't give you pause either?

Now it seems all of my databases are inaccessible.

No. All of your database are gone. Toast. Trashed. "Shuffled off this Mortal Coil...", etc.

Things to do:

  1. Restore your databases from Backup (the ones you've been taking expressly for this kind of "Disaster Recovery" exercise).
  2. Go and read [a little] about how MySQL uses its Data Directory.
  3. In future, try to avoid mucking about with any database at the file system level, if at all possible.

I appreciate you had what appeared to be a file system problem but investigating and [correctly] resolving that issue would have saved you an awful lot of grief.

Phill W.
  • 8,706
  • 1
  • 11
  • 21
  • 1
    Lol, this is funny, because I don't see how the system was trying to indicate to me in any clear manner that "this thing should not be deleted" as you suggest. It simply stated that it was trying to rmdir it but it wasn't empty. So, I disagree with you that the system was trying to tell me "hey don't go trying to manually delete this thing" because that is not what it said. What the system said was "I'm trying to delete this thing, but I can't". :) – Blaine Lafreniere Nov 23 '20 at 15:59
0

mysqlcheck won't help, it's for damaged files.

You should have deleted non-table files in the directory, not the directory itself. Especially if you use MySQL 8, as I suspect. Because your tables metadata are stored in an internal dictionary.

Anyway, don't you have a backup?

If not, recreate the directory and try running individual DROP TABLEs. It may work or not. Let me know how it goes.

Federico Razzoli
  • 1,663
  • 8
  • 24