MySQL says Table 'db.table' doesn't exist but you can see it
ERROR 1146 (42S02): Table 'shop.Orders' doesn't existShort answer
Read the name in the message: it is exactly the database and table MySQL looked for. On Linux, database and table names are case-sensitive by default, so Users and users are different tables. A dump moved from Windows or macOS often fails this way. A TEMPORARY table also vanishes when its session ends.
Fix it fast
1Find out which cause you have
List the tables in that database and compare the real name with the one in the message, letter by letter, including case.
SELECT DATABASE(); SHOW TABLES FROM shop;2Match what you see, then jump to its fix
What does the error look like?
ERROR 1146 (42S02): Table 'shop.Orders' doesn't existER_NO_SUCH_TABLE: Table '%s.%s' doesn't exist
Cause 1 of 2
The table name differs in letter case (Linux server, Windows or macOS dump)
1Check
The manual says names are not case-sensitive on Windows but are case-sensitive in most Unix systems. The default of lower_case_table_names is 0 on Unix, 1 on Windows and 2 on macOS.
SHOW VARIABLES LIKE 'lower_case_table_names';2Fix
Make the query use the exact case that was created, or rename the table to one fixed style, ideally all lowercase. Setting lower_case_table_names to 1 is possible only when the server is initialized; changing it afterwards is prohibited.
RENAME TABLE Orders TO orders;3Verify
The query that failed now finds the table.
SELECT COUNT(*) FROM shop.orders;Confirmed by dev.mysql.com
Cause 2 of 2
The table was a TEMPORARY table and its session ended
1Check
A TEMPORARY table is visible only in the session that made it, and is dropped when that session closes. Connection pools can hand your next query to a different connection.
SHOW TABLES FROM shop;2Fix
Create and use the table on the same connection, or use a normal table if other connections need it.
CREATE TABLE report_cache (id INT PRIMARY KEY, total DECIMAL(10,2));3Verify
A second connection can read the table.
SELECT COUNT(*) FROM shop.report_cache;Confirmed by dev.mysql.com
How do I stop it coming back?
- Pick one naming style, lowercase with underscores, for every table and database.
- Run a restore from another operating system in a scratch server and check the names before production.
- Set lower_case_table_names when initializing a new server if you share dumps between systems.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
SHOW TABLES lists the table, but every query says it does not exist in the engine
SHOW TABLES lists the table, but SELECT on it fails
Error 1932 means the server has the table's .frm definition, but InnoDB has no such table in its own data dictionary.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fix