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
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":
sh-3.2# ls -la data/test
total 0
drwxr-xr-x 3 _mysql wheel 102 Apr 15 12:36 .
drwxr-xr-x 11 _mysql wheel 374 Apr 15 12:28 ..
-rw-r--r-- 1 _mysql wheel 0 Mar 31 10:19 .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 -s -N -username -p information_schema -e 'SELECT Variable_Value FROM GLOBAL_VARIABLES WHERE Variable_Name = "datadir"'
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]:
/var/lib/mysql
or
mysql> select @@datadir;
on MYSQL CLI
and then
cd /var/lib/mysql && rm -rf test/NOTEMPTY
change path based on your result
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.
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
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.
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:
sudo ls -al test
total 0
drwxrwx--- 3 _mysql _mysql 102 Mar 26 16:50 .
drwxrwxr-x 18 _mysql _mysql 612 Apr 7 13:34 ..
-rw-rw---- 1 _mysql _mysql 0 Jun 26 2013 NOTEMPTY
Chmod first and then
sudo rm -rf test/NOTEMPTY
No problems dropping databases after that