1

I am using MySQL v5.1 on Ubuntu machine.

I have a database named my_db which I would like to drop it, so I execute command:

mysql> drop database my_db;

ERROR 1010 (HY000): Error dropping database (can't rmdir './my_db/', errno: 17)

As you see above, there is an error....Why I can not drop database?

P.S. I know all the database related files are located on /var/lib/mysql/my_db/

1
  • From your previous posts, I'd say you've messed up something under /var/lib/mysql. If you're learning, fine. If this is in production, back up /var/lib/mysql, recreate your databases using mysql commands only (never manipulating files) and import the data as best as you can. Nov 30, 2011 at 23:36

3 Answers 3

3

A quick test program shows errno = 17 is "File exists" (just an observation, not that I'd expect you to figure it out before posting).

I found this thread on the mysql site, which suggests that you have files in /var/lib/mysql/my_db/ that mysql didn't create (or that it thinks it didn't create). List the files (you'll need to sudo) and see what's there. Try moving anything there to a temporary directory (or deleting if you're really sure you won't need them), then try again.

1
  • Definitely mv them, not delete. It'd would suck if mysql starts to error out because it can't find the files it wants to delete.
    – user606723
    Nov 30, 2011 at 22:51
0

Check the owner and permissions on /var/lib/mysql/my_db my immediate thought is that the user account running the mysql daemon does not have the proper permissions to remove the folder.

You could kill mysqld and start it as root then try removing the database to test.

0

As far as I can tell you have to check the following:

  1. Check in the directory to see that there aren't any unnecessary files that aren't related to your database. Because the DROP database removes just database files then the directory, and since you probably have other files there that aren't related to the database files it doesn't remove them and hence it cannot remove the directory.
  2. If that doesn't work try to remove the database with PHPMYADMIN, mostly it works with it.

Check these out:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .