Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant drop database nor create database

When I run mysql as root and run SHOW DATABASES; it shows that I have a one_db database, but when I run DROP DATABASE one_db; it outputs the following error:

ERROR 1008 (HY000): Can't drop database 'one_db'; database doesn't exist

I then try to CREATE DATABASE one_db; and outputs this error:

ERROR 1007 (HY000): Can't create database 'one_db'; database exists

How can I delete this database now?


## Here is the whole session (logged in with 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
like image 788
gespinha Avatar asked Jul 05 '15 11:07

gespinha


1 Answers

To fix, can manually cleanup the mysql files relating to the one_db database :

manual cleanup process

  1. Find the datadir path for mysql by running ( at mysql shell ) :

      show variables where Variable_name ='datadir';
    
  2. Stop mysql server

  3. remove the one_db directory under the 'datadir'

  4. restart mysql server and verify database one_db is not present

like image 173
amdixon Avatar answered Oct 01 '22 17:10

amdixon