开发者

how to drop database

开发者 https://www.devze.com 2022-12-15 22:26 出处:网络
i used the following sytanx drop database filmo; and got the following error: ERROR 1010 (HY000): Error dropping database (can\'t开发者_如何学JAVA rmdir \'./filmo/\', errno: 17)

i used the following sytanx

drop database filmo; 

and got the following error:

ERROR 1010 (HY000): Error dropping database (can't开发者_如何学JAVA rmdir './filmo/', errno: 17)

any ideas..


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.


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.


sudo rm -rf /var/lib/mysql/db_production

where db_production is the name of the database

Remember to use "sudo".


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.


This is what I do on Mac OS X Mavericks:

  1. Stop the MySQL service
  2. Remove the directory at /usr/local/mysql/data


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 .


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)


This is amazingly old, but another thing to check is the data folder. On Windows, that should be C:\ProgramData\MySQL<Version>\Data. IN my case, I was getting a 'cannot find folder' error.

I found that somehow the data folder for my database had been deleted. I imagine it was user error. I added a blank folder with the database name, and when I went back the DROP the table, it went as expected. Took me a while to find out what had happened, but hopefully this will save someone else the heartache.


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"


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';


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)


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.


drop database <database_name>;
0

精彩评论

暂无评论...
验证码 换一张
取 消