删除数据库时出错(无法 rmdir '.test\',错误号:17)
基本上,我学习了如何使用“mysqladmin -u root -p password”命令创建 root 密码,这都是通过 Windows 命令编辑器完成的。现在,下一个过程是显示默认数据库(info.schema、mysql 和 test),这是通过使用“SHOW DATABASES;”实现的。
但根据书上的说法,我们必须删除多余的测试文件,然后会弹出以下错误:
删除数据库时出错(无法 rmdir '.test\',errno: 17)
使用的命令是 DROP DATABASE test;
我正在使用 MYSQL 和 PHPMYADMIN。有关如何无错误地删除文件的任何帮助吗?
Basically, I was taught on how to create a root password using the "mysqladmin -u root -p password" command, this was done all through the windows command editor. Now, the next process was to display the default databases (info. schema, mysql and test) which was achieved by using "SHOW DATABASES;"
But according to the book, we had to delete the redundant test file and the following error pops up:
Error Dropping Database (Can't rmdir '.test\', errno: 17)
The command put to use was DROP DATABASE test;
I am using MYSQL and PHPMYADMIN. Any help on how to drop the file with no errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(19)
数据库由数据目录下的一个目录(通常是
/var/lib/mysql
)表示,该目录用于存储表数据。DROP DATABASE 语句将删除所有表文件,然后删除代表数据库的目录。但是,它不会删除非表文件,从而无法删除目录。
当 MySQL 无法删除目录时,它会显示一条错误消息,
您实际上可以通过删除数据库目录中的任何剩余文件,然后删除目录本身来手动删除数据库。
A database is represented by a directory under the data directory (usually
/var/lib/mysql
), and the directory is intended for storage of table data.The
DROP DATABASE
statement will remove all table files and then remove the directory that represented the database. It will not, however, remove non-table files, whereby making it not possible to remove the directory.MySQL displays an error message when it cannot remove the directory
you can really drop the database manually by removing any remaining files in the database directory and then the directory itself.
我在 Mac 上新安装 mysql 5.5 时遇到了同样的问题。我尝试删除测试架构并收到 errno 17 消息。 errno 17 是某些 posix os 函数返回的错误,指示文件存在于不应存在的位置。在数据目录中,我发现了一个奇怪的文件“.empty”:
一旦我rm'd该.empty文件,删除数据库命令就成功了。
我不知道 .empty 文件来自哪里;如前所述,这是一个新的 mysql 安装。也许是安装过程中出现了问题。
I ran into this same issue on a new install of mysql 5.5 on a mac. I tried to drop the test schema and got an errno 17 message. errno 17 is the error returned by some posix os functions indicating that a file exists where it should not. In the data directory, I found a strange file ".empty":
Once I rm'd the .empty file, the drop database command succeeded.
I don't know where the .empty file came from; as noted, this was a new mysql install. Perhaps something went wrong in the install process.
转至 mysql 安装的 datadir* 并手动 rm 数据库。然后
,
注意:
* 要检查您的安装的 datadir,
Go to the datadir* for your mysql installation and rm the databases manually. It can be
Then,
Notes:
* To check datadir for your installation,
对于phpmyadmin,转到xampp\mysql\data并简单地删除数据库文件夹。为我工作!
For phpmyadmin, go to xampp\mysql\data and simply delete the database folder. Worked for me !!
如果是 XAMPP,请执行以下操作:
希望这会有所帮助。
If it is XAMPP, Do the following:
Hope this helps.
我刚刚遇到了 WAMP 和它附带的 phpMyAdmin 的问题。删除数据库并使错误消失。我进入 C:\wamp\bin\mysql\mysql5.5.24\data\ 并删除了相关数据库的文件夹。
然后我刷新了phpMyAdmin页面,数据库就消失了。
I just ran into this problem with WAMP and the phpMyAdmin that comes with it. To remove the database and make the error go away. I went into
C:\wamp\bin\mysql\mysql5.5.24\data\
and deleted the folder for the database in question.Then I refreshed the page at phpMyAdmin, and the database was gone.
只是添加到到目前为止的响应:在 Windows 10 中,数据文件保存在这里...
C:\ProgramData\MySQL\MySQL Server [mn]\data
每个模式都有目录在你的数据库中。您将需要进入要删除的架构,手动删除任何多余的文件,然后再次尝试删除命令。
针对数据库的任何工作台更改都将存储在此位置。例如,我在对我的一个数据库进行逆向工程练习并将更改保存到此位置的 .mwb 文件中时遇到此错误。
Just to add to the responses so far: In Windows 10, the data files are kept here...
C:\ProgramData\MySQL\MySQL Server [m.n]\data
There will be directories for each schema in your database. You will want to go inside the schema you are trying to drop, manually delete any superfluous files then try the drop command again.
Any workbench changes against a database will get stored in this location. For example, I had this error following a reverse engineering exercise on one of my databases and saving the changes which get stored in a .mwb file in this location.
该命令将仅从 MySQL 的内部 information_schema 数据库中选择值,并禁用表格输出和列标题。
Linux 上的输出[我的结果]:
或
在 MYSQL CLI 上
,然后
根据结果更改路径
The command will select the value only from MySQL's internal information_schema database and disables the tabular output and column headers.
Output on Linux [mine result]:
or
on MYSQL CLI
and then
change path based on your result
我的情况是,问题是数据库目录中残留的转储文件。该文件可能是在我一直在进行的备份脚本测试期间生成的。
一旦我手动删除该文件,我就可以删除数据库。
I my case the problem was a residual dump file in the database directory. That file was probably generated during a backup script test I had been working on.
Once I manually deleted the file I could then drop the database.
可以删除sql目录下的数据。
对我来说,我在 Windows 10 上使用 AMPPS。
我转到 AMPPs 安装目录。
对我来说是:
因为我已将它安装在我的辅助驱动器上。
然后刷新你的 SQL 客户端,你会发现它消失了。
You can delete the data in the sql directory.
For me i was using AMPPS on windows 10.
I went to the AMPPs installtion directory.
for me it was :
because i have it installed on my secondary drive.
Then refresh your SQL client and you will see it's gone.
您可能需要检查两件事。
1- 数据库文件夹权限 要删除的数据库必须与mysql进程具有相同的所有者。
2- 目录必须为空 转到 mysql 数据目录并验证该目录是否为空
然后连接 mysql cli 并再次运行 drop database 命令。
You may need to check two things.
1- Database Foleder's permission The database you wants to delete must have the same owner as mysql process has.
2- Directory Must be empty Goto the mysql data directory and verify that directory is empty
After that connect your mysql cli and run drop database command again.
执行此操作并删除所选数据库中相应的缓存文件,然后删除数据库
首先找到包含所选数据库的 MySQL 数据目录
Linux
搜索术语“datadir”:/datadir
如果存在,它将突出显示一行:datadir = [path]
您也可以手动查找该行。它通常可以在 [mysqld] 的节标题下找到,但不一定必须在那里找到。
如果该行不存在,则 MySQL 将默认为:/var/lib/mysql。
Windows
1. 在记事本中打开 MySQL 的配置文件: my.ini
my.ini 将位于 MySQL 程序文件夹中,该文件夹位于 MySQL 的安装位置。如果您没有安装MySQL,则使用Windows“搜索”功能来查找my.ini。您还可以通过浏览到 [drive]:\Program Files\MySQL\MySQL Server 5.5 来手动搜索它。
在记事本中进行搜索以查找术语“datadir”。
如果存在,它将突出显示一行:datadir = [path]
您也可以手动查找那条线。它通常可以在 [mysqld] 的节标题下找到,但不一定必须在那里找到。
如果该行不存在,那么您可能会在 [drive]:\ProgramData\MySQL\MySQL Server 5.5\data 下找到它。
注意:“ProgramData”文件夹可能是隐藏的。您可能必须在 Windows 资源管理器中输入显式路径
Go through this and remove corresponding cache files in selected db then after you can drop your database
First find Your MySQL Data Directory Containing Your selected DB
Linux
Search for the term "datadir": /datadir
If it exists, it will highlight a line that reads: datadir = [path]
You can also manually look for that line. It typically would be found under a section heading of [mysqld] but it does not necessarily have to be found there.
If that line does not exist, then MySQL will default to: /var/lib/mysql.
Windows
1. Open up MySQL's configuration file into Notepad: my.ini
The my.ini will be located in the MySQL program folder, which would be wherever it got installed. If you did not install MySQL, then use the Windows "search" feature to look for my.ini. You could also manually search for it by browsing to [drive]:\Program Files\MySQL\MySQL Server 5.5.
Do a search in Notepad to find the term "datadir".
If it exists, it will highlight a line that reads: datadir = [path]
You can also manually look for that line. It typically would be found under a section heading of [mysqld] but it does not necessarily have to be found there.
If that line does not exist, then you'll probably find it under [drive]:\ProgramData\MySQL\MySQL Server 5.5\data.
NOTE: The "ProgramData" folder may be hidden. You may have to type the explicit path into Windows Explore
就我而言,我在
phpMyAdmin
上的数据库下没有看到任何表格,我使用的是Wamp 服务器
,但是当我检查C:\wamp\bin 下的目录时\mysql\mysql5.6.12\data
当我手动删除此文件时,我发现了这个employed.ibd
,我能够从phpMyAdmin
顺利,没有任何问题。drop
数据库In my case I didn't see any tables under my database on
phpMyAdmin
I am usingWamp server
but when I checked the directory underC:\wamp\bin\mysql\mysql5.6.12\data
I found thisemployed.ibd
when I deleted this file manually I was able todrop
the database fromphpMyAdmin
smoothly without any problems.我遇到了同样的问题(Mac 上的 mysql 5.6),删除数据库时出现“can't rmdir..”错误。留下一个空的数据库目录是不可能删除的。感谢@Framework 和@Beel 提供的解决方案。
我首先从终端删除了 db 目录(/Applications/XAMPP/xamppfiles/var/mysql)。
为了进一步删除数据库,我还删除了空的测试文件。在我的例子中,该文件名为NOTEMPTY,但仍然包含0:
首先Chmod,然后
删除数据库没有问题
I had the same issue (mysql 5.6 on mac) with 'can't rmdir..'-errors when dropping databases. Leaving an empty database directory not possible to get rid of. Thanks @Framework and @Beel for the solutions.
I first deleted the db directory from the Terminal in (/Applications/XAMPP/xamppfiles/var/mysql).
For further db drops, I also deleted the empty test file. In my case the file was called NOTEMPTY but still containing 0:
Chmod first and then
No problems dropping databases after that
只需转到数据目录,在我的情况下,路径是“wamp\bin\mysql\mysql5.6.17\data”,在这里您将看到所有数据库文件夹,只需删除此数据库文件夹,数据库将自动下降:)
just go to data directory in my case path is "wamp\bin\mysql\mysql5.6.17\data" here you will see all databases folder just delete this your database folder the db will automatically drooped :)
我遇到了这个问题,当我检查数据库目录时,有许多
exp
文件(ibd
和frm
文件有已被删除)。列出文件以查看它们的属性(因为所有者已经对文件具有读写权限)手册页显示
您实际上可以
chattr -e
这些文件,但 mysql 仍然不会让您删除数据库。但是,使用 rm 删除文件可以干净地删除数据库。I ran into this problem, and when I checked out the database directory, there were a number of
exp
files (theibd
andfrm
files had been removed). Listing the files to look at their attributes (since the owner already had rw privileges on the files)Man page says
You actually can
chattr -e
these files, but mysql still won't let you drop the database. Removing the files withrm
, however, allows the database to be dropped cleanly.发生这种情况是因为您可能已将 /var/lib/mysql 文件夹的数据库文件夹从另一台服务器复制到您的服务器。但您还没有复制这些文件:
/var/lib/mysql/ib_buffer_pool
/var/lib/mysql/ibdata1
/var/lib/mysql/ib_logfile0
/var/lib/mysql/ib_logfile1
/var/lib/mysql/ibtmp1
因此,您可以创建一个新的数据库和表,您可以删除它们,但不能删除从另一台服务器复制的数据库,并且您也无法浏览从另一台服务器复制的同一数据库。
所以我还复制了这些文件: ib_buffer_pool、ibdata1、ib_logfile0、ib_logfile1、ibtmp1 之后一切正常。
It happens because you may have copied /var/lib/mysql folder's database folder from another server to your server. But you haven't copied these files:
/var/lib/mysql/ib_buffer_pool
/var/lib/mysql/ibdata1
/var/lib/mysql/ib_logfile0
/var/lib/mysql/ib_logfile1
/var/lib/mysql/ibtmp1
So you can create a new db and tables you are able to drop them but you can't drop the databases that you have copied from another server and you are also not able to explore the same database that you copied from another server.
So I also copied that files : ib_buffer_pool,ibdata1,ib_logfile0,ib_logfile1,ibtmp1 after that everything worked.
任何来自 Manjaro/Arch 的人,使用 PHP8 安装 XAMPP,然后降级到 7.4 都会遇到此错误。要修复此问题,只需使用 Thunar 作为 root 用户转到 /opt/lampp/var/mysql/,然后删除具有相同数据库名称的数据库文件,数据库就会消失。您可以使用 PhpMyAdmin 获取数据库名称。
Anybody coming from Manjaro/Arch, installing XAMPP with PHP8 and then downgrading to 7.4 will get this error. To fix, simply go to /opt/lampp/var/mysql/ with Thunar as root user, and delete the database file with the same database name in question and database should be gone. You can get the database name with PhpMyAdmin.
我遇到了同样的问题,我无法删除数据库,它给出了相同的错误:
我在工作中使用
xampp
,所以我转到了该文件夹我安装了xampp
,在xampp文件夹中找到mysql
文件夹,在mysql文件夹中找到data
文件夹,最后在data中找到您正在查找的数据库并打开您的数据库文件夹并删除所有内容。最后转到您的 phpmyadmin 并删除特定数据库。
I faced the same problem, I was unable to delete a database, it was giving the same error:
I am using
xampp
for my work, so I went to the folder that I installedxampp
, inside xampp folder findmysql
folder, inside mysql folder finddata
folder and finally inside data find the database that you are looking for and open your database folder and delete everything.And at the end go to your phpmyadmin and delete specific database.