How to fix ERROR 1010: Error dropping database (can't rmdir) in MySQL

MySQLINTERMEDIATEMEDIUMUpdated Mar 12, 2026· 249 views

ERROR 1010 occurs when MySQL cannot remove a database directory due to extra files or permission issues. The directory contains files that MySQL doesn't recognize or can't delete, preventing the DROP DATABASE command from completing successfully.

Quick fix

Fixes ERROR 1010: Error dropping database (can't rmdir)

SHOW VARIABLES WHERE Variable_name LIKE 'datadir%';
  1. Check the MySQL data directory location
  2. Stop the MySQL server
  3. List files in the database directory
  4. Remove extra files manually
mysql — error
SHOW VARIABLES WHERE Variable_name LIKE 'datadir%';
ERROR 1010: Error dropping database (can't rmdir)

What this error means

MySQL ERROR 1010 (HY000) is a file system error that occurs during the DROP DATABASE operation. When you drop a database, MySQL removes the associated table files (.ibd, .frm, etc.) and then attempts to delete the database directory itself. If the directory is not empty or contains files that MySQL doesn't recognize—such as backups, temporary files, or binary log files—the directory removal fails. The error is accompanied by an errno value that provides more context: - errno 17: "File exists" - the directory contains unrecognized MySQL files - errno 39: "Directory not empty" - hidden or extra files remain - errno 41: Similar directory removal issue This is typically a file system permission or cleanup issue rather than a MySQL functionality problem.

Typical symptoms

  • DROP DATABASE command fails with "Error dropping database (can't rmdir)"
  • Error includes an errno value (17, 39, or 41)
  • Database records in MySQL are gone but directory removal fails
  • Database can be recreated with the same name only after manual directory removal

Common causes

  1. Extra files in the database directory not created by MySQL (backups, temporary files, hidden files)
  2. Binary log files stored in a subdirectory of the MySQL data directory
  3. Insufficient file system permissions for the MySQL system user to delete the directory
  4. Files locked by other processes or applications preventing removal
  5. Hidden system files (.DS_Store on macOS, thumbs.db on Windows) in the database directory

How to fix "ERROR 1010: Error dropping database (can't rmdir)"

1Check the MySQL data directory location

First, find where MySQL stores database files:

sql
SHOW VARIABLES WHERE Variable_name LIKE 'datadir%';

This typically returns /var/lib/mysql/ on Linux, /usr/local/mysql/data/ on macOS, or C:\ProgramData\MySQL\MySQL Server 8.0\Data\ on Windows.

2Stop the MySQL server

Before manually removing files, stop MySQL to prevent any locking issues:

Linux (systemd):

bash
sudo systemctl stop mysql

Linux (service):

bash
sudo service mysql stop

macOS:

bash
sudo /usr/local/mysql/support-files/mysql.server stop

Windows (Command Prompt as Administrator):

cmd
NET STOP MySQL80
3List files in the database directory

Navigate to the data directory and list all files (including hidden ones) in the problematic database folder:

Linux/macOS:

bash
ls -la /var/lib/mysql/database_name/

Windows (PowerShell):

powershell
Get-ChildItem -Path "C:\ProgramData\MySQL\MySQL Server 8.0\Data\database_name" -Force

Look for files that don't belong, such as:
- .DS_Store or Thumbs.db (system files)
- .backup or .bak files
- .sql or .dump files
- Any hidden files (prefix with dot)

4Remove extra files manually

Delete the unrecognized files from the directory:

Linux/macOS:

bash
cd /var/lib/mysql/database_name/
rm -f extra_file.txt
rm -f .DS_Store

Windows (PowerShell as Administrator):

powershell
cd "C:\ProgramData\MySQL\MySQL Server 8.0\Data\database_name"
Remove-Item -Path "extra_file.txt" -Force
Remove-Item -Path ".DS_Store" -Force

If the directory is now completely empty, you can optionally remove it:

Linux/macOS:

bash
cd /var/lib/mysql/
rmdir database_name
5Restart the MySQL server

Start MySQL again:

Linux (systemd):

bash
sudo systemctl start mysql

Linux (service):

bash
sudo service mysql start

macOS:

bash
sudo /usr/local/mysql/support-files/mysql.server start

Windows (Command Prompt as Administrator):

cmd
NET START MySQL80
6Retry the DROP DATABASE command

Now attempt to drop the database again:

sql
DROP DATABASE database_name;

The command should succeed now that the directory contains only MySQL-managed files.

Advanced notes

Binary Logs in Data Directory: If you see mysql-bin/ or similar binary log directories inside your data directory, update your MySQL configuration file (my.cnf or my.ini) to store binary logs elsewhere:

ini
[mysqld]
log_bin = /var/log/mysql/mysql-bin

Then restart MySQL and retry the DROP DATABASE command.

Permission Issues: If you see "Permission denied" errors, ensure the MySQL system user owns the data directory:

bash
sudo chown -R mysql:mysql /var/lib/mysql/
sudo chmod 750 /var/lib/mysql/

SELinux/AppArmor: On systems with mandatory access controls, check that MySQL has permission to access and delete files in the data directory. You may need to consult your system's security policies.

Backups Before Deletion: Always verify you have backups of any data before manually deleting files. If the database needs to be recovered, ensure you have dumps or backups in another location.

Frequently asked questions

What does "ERROR 1010: Error dropping database (can't rmdir)" mean?
MySQL ERROR 1010 (HY000) is a file system error that occurs during the DROP DATABASE operation. ) and then attempts to delete the database directory itself. If the directory is not empty or contains files that MySQL doesn't recognize—such as backups, temporary files, or binary log files—the directory removal fails.
How do I fix "ERROR 1010: Error dropping database (can't rmdir)"?
ERROR 1010 occurs when MySQL cannot remove a database directory due to extra files or permission issues. The directory contains files that MySQL doesn't recognize or can't delete, preventing the DROP DATABASE command from completing successfully.
What causes "ERROR 1010: Error dropping database (can't rmdir)"?
Extra files in the database directory not created by MySQL (backups, temporary files, hidden files) Binary log files stored in a subdirectory of the MySQL data directory Insufficient file system permissions for the MySQL system user to delete the directory
Is the "ERROR 1010: Error dropping database (can't rmdir)" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading