MySQL 如何删除数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2046681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to drop database
提问by devang
i used the following sytanx
我使用了以下 sytanx
drop database filmo;
and got the following error:
并得到以下错误:
ERROR 1010 (HY000): Error dropping database (can't rmdir './filmo/', errno: 17)
any ideas..
有任何想法吗..
回答by tanerkay
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.
这意味着该目录中有与 MySQL 无关的文件。另一个问题,尽管我对此表示怀疑,是权限不足。您可以从文件系统中删除该目录。
回答by Alex R
Got same error. This fixed it for me in Ubuntu 10.04:
得到同样的错误。这在 Ubuntu 10.04 中为我修复了:
stop mysql
stop mysql
rm -rf /var/lib/mysql/XXXXX
rm -rf /var/lib/mysql/XXXXX
start mysql
start mysql
Where XXXXX is the offending database name.
其中 XXXXX 是有问题的数据库名称。
回答by Jones Agyemang
sudo rm -rf /var/lib/mysql/db_production
须藤 rm -rf /var/lib/mysql/db_production
where db_production is the name of the database
其中 db_production 是数据库的名称
Remember to use "sudo".
请记住使用“sudo”。
回答by Higo Matos
This is what I do on Mac OS X Mavericks:
这就是我在 Mac OS X Mavericks 上所做的:
- Stop the MySQL service
- Remove the directory at
/usr/local/mysql/data
- 停止 MySQL 服务
- 删除目录在
/usr/local/mysql/data
回答by gandy
1) rm -rf /var/lib/mysql/data/***
keep the data dir , rm the contents of data/
1)rm -rf /var/lib/mysql/data/***
保持数据目录,rm数据的内容/
2) use
2) 使用
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 .
那么再次重新创建数据数据库就可以了。希望它会有所帮助,注意,直接删除数据目录是没有用的,无论您是否重新启动 mysqld。
回答by Anghel Florin
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.
我已经更改了 mysql 文件夹( windows server c:\xampp\mysql
)的权限并且现在正在工作,我已经创建并删除了数据库,没有任何错误。
回答by jspcal
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"
你对该目录(和父目录)有写权限吗?您可能需要递归地使目录可写(Windows 中的安全选项卡或 nix 中的 chmod)并删除任何非数据库文件,如“Thumbs.db”
回答by saeed foroughi
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:
我遇到了这个问题,似乎与您的 mysql 用户权限有关。如果确实有效,请尝试由 root 用户执行此操作,请以 root 用户身份使用此命令来授予您的用户权限:
grant drop
execute on *.* to 'your-user-name'@'user-ip';
回答by LawrenceLi
Here is a way to simulate your error
这是一种模拟错误的方法
1.create a directory on MySQL data directory
1.在MySQL数据目录上创建一个目录
mkdir /data/mysql/data/filmo
2.check the last item
2.检查最后一项
[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
3.在其中创建一个转储文件
[root@linux]# mysqldump -uroot -p123456 -B mysql>/data/mysql/data/filmo/dump_file.sql
4.MySQL will believe filmo is a database
4.MySQL会认为filmo是一个数据库
[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
5.当我删除这个“数据库”时,这是你的错误
[root@linux]# mysql -uroot -p123456 -e"drop database filmo;"
ERROR 1010 (HY000) at line 1: Error dropping database (can't rmdir './filmo/', errno: 17)
回答by Raj Talreja
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
当您在 ibdata1 文件(用于 innodb 引擎)中有错误的 TABLESPACE 时,通常会出现该错误 innodb 引擎将一些设置存储在 ibdata1 文件中
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)
如果您最近将文件复制/移动到其他服务器或尝试恢复,那么您也应该移动 ibdata1 文件,然后您可以删除数据库。我假设您遇到的问题是表不存在,现在正在删除数据库?如果是,则停止 mysql 服务,然后删除文件,然后再次创建 db,这将对您有所帮助。进一步在这里这可能对你有帮助 [ Error Dropping Database (Can't rmdir '.test\', errno: 17)