Can't drop a database or create a database
When I start mysql as root and start SHOW DATABASES;
it shows that I have a database one_db
, but when I start DROP DATABASE one_db;
it throws the following error:
ERROR 1008 (HY000): Can't drop database 'one_db'; database doesn't exist
Then I try CREATE DATABASE one_db;
and it outputs this error:
ERROR 1007 (HY000): Can't create database 'one_db'; database exists
How can I delete this database now?
## Here is the entire session (logged in as root) ##
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| one_db |
+--------------------+
4 rows in set (0.00 sec)
mysql> DROP DATABASE one_db;
ERROR 1008 (HY000): Can't drop database 'one_db'; database doesn't exist
mysql> CREATE DATABASE one_db;
ERROR 1007 (HY000): Can't create database 'one_db'; database exists
source to share
To fix the error, you can manually clear the mysql files related to the database one_db
:
manual cleaning process
Find the datadir path for mysql by running (in mysql shell):
show variables where Variable_name ='datadir';
Stop mysql server
delete the one_db directory under 'datadir' section
restart mysql server and check database one_db no
source to share