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.
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.
First, find where MySQL stores database files:
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.
Before manually removing files, stop MySQL to prevent any locking issues:
Linux (systemd):
sudo systemctl stop mysqlLinux (service):
sudo service mysql stopmacOS:
sudo /usr/local/mysql/support-files/mysql.server stopWindows (Command Prompt as Administrator):
NET STOP MySQL80Navigate to the data directory and list all files (including hidden ones) in the problematic database folder:
Linux/macOS:
ls -la /var/lib/mysql/database_name/Windows (PowerShell):
Get-ChildItem -Path "C:\ProgramData\MySQL\MySQL Server 8.0\Data\database_name" -ForceLook 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)
Delete the unrecognized files from the directory:
Linux/macOS:
cd /var/lib/mysql/database_name/
rm -f extra_file.txt
rm -f .DS_StoreWindows (PowerShell as Administrator):
cd "C:\ProgramData\MySQL\MySQL Server 8.0\Data\database_name"
Remove-Item -Path "extra_file.txt" -Force
Remove-Item -Path ".DS_Store" -ForceIf the directory is now completely empty, you can optionally remove it:
Linux/macOS:
cd /var/lib/mysql/
rmdir database_nameStart MySQL again:
Linux (systemd):
sudo systemctl start mysqlLinux (service):
sudo service mysql startmacOS:
sudo /usr/local/mysql/support-files/mysql.server startWindows (Command Prompt as Administrator):
NET START MySQL80Now attempt to drop the database again:
DROP DATABASE database_name;The command should succeed now that the directory contains only MySQL-managed files.
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:
[mysqld]
log_bin = /var/log/mysql/mysql-binThen 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:
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.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions