问题
i used the following sytanx
drop database filmo;
and got the following error:
ERROR 1010 (HY000): Error dropping database (can't rmdir './filmo/', errno: 17)
any ideas..
回答1:
It means there are files in that directory not relating to MySQL. Another issue, although I doubt it, is insufficient permissions. You may delete that directory from the filesystem.
回答2:
Got same error. This fixed it for me in Ubuntu 10.04:
stop mysql
rm -rf /var/lib/mysql/XXXXX
start mysql
Where XXXXX is the offending database name.
回答3:
sudo rm -rf /var/lib/mysql/db_production
where db_production is the name of the database
Remember to use "sudo".
回答4:
I've changed the permissions on mysql folder ( windows server c:\xampp\mysql
) and is working now, I've created and dropped databases without any error.
回答5:
This is what I do on Mac OS X Mavericks:
- Stop the MySQL service
- Remove the directory at
/usr/local/mysql/data
回答6:
1) rm -rf /var/lib/mysql/data/***
keep the data dir , rm the contents of data/
2) use
mysql -uxxx -pyyy
$ drop database data;
then it would be ok to recreate the data database again. hopefully it will help, Attention , direct remove data dir is useless, whatever you restart mysqld or not .
回答7:
do you have write permission on that directory (and the parent)? you may need to recursively make the directory writable (security tab in windows or chmod in nix) and delete any non-db files like "Thumbs.db"
回答8:
I had this problem and it seems to be about your mysql user permissions. try doing it by root user if it did work use this command as root to grand drop permission to your user:
grant drop
execute on *.* to 'your-user-name'@'user-ip';
回答9:
Here is a way to simulate your error
1.create a directory on MySQL data directory
mkdir /data/mysql/data/filmo
2.check the last item
[root@linux]# ls -ltrh /data/mysql/data/
总用量 173M
-rw-rw---- 1 mysql mysql 48M 4月 17 11:00 ib_logfile1
drwx------ 2 mysql mysql 4.0K 4月 17 11:00 performance_schema
drwx------ 2 mysql mysql 4.0K 4月 17 11:00 mysql
-rw-rw---- 1 mysql mysql 56 4月 18 06:01 auto.cnf
drwxr-xr-x 2 root root 4.0K 4月 18 07:25 backup
-rw-rw---- 1 mysql mysql 19 4月 23 07:29 mysql-bin.index
-rw-rw---- 1 mysql mysql 5 4月 23 07:29 oldboylinux.pid
-rw-rw---- 1 mysql mysql 19K 4月 23 07:29 error.log
-rw-rw---- 1 mysql mysql 76M 4月 23 09:56 ibdata1
-rw-rw---- 1 mysql mysql 48M 4月 23 09:56 ib_logfile0
-rw-rw---- 1 mysql mysql 5.9K 4月 23 10:21 mysql-bin.000001
drwxr-xr-x 2 root root 4.0K 4月 23 10:36 filmo
3.create a dump file in it
[root@linux]# mysqldump -uroot -p123456 -B mysql>/data/mysql/data/filmo/dump_file.sql
4.MySQL will believe filmo is a database
[root@linux]# mysql -uroot -p123456 -e"show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| backup |
| filmo |
| mysql |
| performance_schema |
+--------------------+
5.when I drop this "database",here is your error
[root@linux]# mysql -uroot -p123456 -e"drop database filmo;"
ERROR 1010 (HY000) at line 1: Error dropping database (can't rmdir './filmo/', errno: 17)
回答10:
That error usually comes when you have wrong TABLESPACE in ibdata1 file (that's for innodb engine) innodb engine store some settings inside ibdata1 file
if you have recently copied / moved your files to other server or tried to restore then you should move ibdata1 file aswell then you can delete the db. I assume you are having issue like table doesn't exist and now deleting db? if yes then stop mysql service then delete files and then create db again, that will help you. Further here this might help you [Error Dropping Database (Can't rmdir '.test\', errno: 17)
回答11:
Not sure where I got this answer from (apologies) but, although similar to the above, it has the additional info of how to find the mysql data directory:
mysql -e "select @@datadir"
This, I assume, is generic and returns the path to mysql/data. If you move to that directory (unix/linux/macOS command):
cd path_to_mysql/data
you will find the database you want to remove, which on nix can be done by:
sudo rm -rf DB_NAME
On MacOS X (10.9.5) I did not have to stop MySQL, but this may differ on other platforms.
回答12:
drop database <database_name>;
来源:https://stackoverflow.com/questions/2046681/how-to-drop-database