MySQL 8.4Lab-verified · 2026-12-02

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

There is no database with exactly that name on the server.

MySQL 8.4.13
1008 (HY000): Can't drop database 'shop_test'; database doesn't exist

Jump to a cause

  1. 01The database was already dropped (or never created)
  2. 02The name's case differs (Linux, lower_case_table_names = 0)

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-12-02 · container image mysql:8.4

DROP DATABASE fails with 1008 when MySQL cannot find a database with exactly the name you wrote. Check the name with SHOW DATABASES or information_schema.schemata before anything else.

On Linux, database names are case-sensitive by default (lower_case_table_names = 0), so ShopTest and shoptest are different databases.

01The database was already dropped (or never created)

shop_test was dropped earlier, so the second DROP DATABASE shop_test fails. SHOW DATABASES LIKE 'shop%' returns Empty set. Typical in cleanup scripts that run more than once.

Setup
Setuprun as root
CREATE DATABASE shop_test;
DROP DATABASE shop_test;
OUTPUT
Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Reproducerun as root
DROP DATABASE shop_test;
✕ ERROR
ERROR 1008 (HY000): Can't drop database 'shop_test'; database doesn't exist
Check the causerun as root
SHOW DATABASES LIKE 'shop%';
OUTPUT
Empty set (0.00 sec)

DROP DATABASE IF EXISTS does not fail; it finishes with 1 warning.

Fix: run the corrected statementrun as root
DROP DATABASE IF EXISTS shop_test;
SHOW DATABASES LIKE 'shop%';
✓ SUCCESS
Query OK, 0 rows affected, 1 warning (0.00 sec)

Empty set (0.00 sec)

02The name's case differs (Linux, lower_case_table_names = 0)

The database was created as ShopTest, but DROP DATABASE shoptest was run. @@lower_case_table_names is 0, so names are compared exactly. Searching information_schema.schemata with LOWER(schema_name) finds the real name ShopTest.

Setup
Setuprun as root
CREATE DATABASE ShopTest;
OUTPUT
Query OK, 1 row affected (0.01 sec)
Reproducerun as root
DROP DATABASE shoptest;
✕ ERROR
ERROR 1008 (HY000): Can't drop database 'shoptest'; database doesn't exist
Check the causerun as root
SELECT @@lower_case_table_names;
SELECT schema_name FROM information_schema.schemata WHERE LOWER(schema_name) = 'shoptest';
OUTPUT
+--------------------------+
| @@lower_case_table_names |
+--------------------------+
|                        0 |
+--------------------------+
1 row in set (0.00 sec)

+-------------+
| SCHEMA_NAME |
+-------------+
| ShopTest    |
+-------------+
1 row in set (0.00 sec)

Use the exact name shown by SHOW DATABASES. After DROP DATABASE ShopTest the database is gone.

Fix: run the corrected statementrun as root
DROP DATABASE ShopTest;
SHOW DATABASES LIKE 'Shop%';
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)

Empty set (0.00 sec)

FAQ

How do I fix MySQL error 1008 database doesn't exist?

Check the exact name with SHOW DATABASES. If the database may already be gone, use DROP DATABASE IF EXISTS. If the case differs, use the name exactly as listed.

The database exists but DROP DATABASE says it doesn't exist

On Linux the case may differ. In our test ShopTest existed, DROP DATABASE shoptest failed with 1008, and DROP DATABASE ShopTest worked.

Is DROP DATABASE IF EXISTS safe to put in scripts?

It does not fail when the database is missing; it only adds a warning. It still drops the database and all its tables when it does exist, so make sure the name is right.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13