how to drop database

2020-02-23 06:52发布

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..

12条回答
Explosion°爆炸
2楼-- · 2020-02-23 07:07

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"

查看更多
孤傲高冷的网名
3楼-- · 2020-02-23 07:08

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 .

查看更多
甜甜的少女心
4楼-- · 2020-02-23 07:11

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.

查看更多
▲ chillily
5楼-- · 2020-02-23 07:15

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)
查看更多
时光不老,我们不散
6楼-- · 2020-02-23 07:21

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

where db_production is the name of the database

Remember to use "sudo".

查看更多
该账号已被封号
7楼-- · 2020-02-23 07:23

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.

查看更多
登录 后发表回答