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
CREATE DATABASE shop_test;
DROP DATABASE shop_test;Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)DROP DATABASE shop_test;ERROR 1008 (HY000): Can't drop database 'shop_test'; database doesn't existSHOW DATABASES LIKE 'shop%';Empty set (0.00 sec)DROP DATABASE IF EXISTS does not fail; it finishes with 1 warning.
DROP DATABASE IF EXISTS shop_test;
SHOW DATABASES LIKE 'shop%';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
CREATE DATABASE ShopTest;Query OK, 1 row affected (0.01 sec)DROP DATABASE shoptest;ERROR 1008 (HY000): Can't drop database 'shoptest'; database doesn't existSELECT @@lower_case_table_names;
SELECT schema_name FROM information_schema.schemata WHERE LOWER(schema_name) = 'shoptest';+--------------------------+
| @@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.
DROP DATABASE ShopTest;
SHOW DATABASES LIKE 'Shop%';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