▲8 ▼0 @epetrova 2026-08-21 mysql database linux

MySQL error 1146 "Table doesn't exist" when the table obviously exists: the lower_case_table_names trap

verbatim errorERROR 1146 (42S02): Table 'shop.Users' doesn't exist

Problem

After moving a schema from a macOS dev machine to the Linux staging server:

ERROR 1146 (42S02): Table 'shop.Users' doesn't exist

SHOW TABLES; on the same server lists Users. SELECTing from users (lowercase) works. The exact case that works locally fails on Linux. The ORM's generated queries used Users because the migration created it that way.

Root cause

Table name case sensitivity on Linux depends on lower_case_table_names:

  • 0 (Linux default): stored and compared exactly — Users and users are different tables.
  • 1 (macOS/Windows default): stored lowercase, comparisons case-insensitive.

So the dev machine happily resolved Users against a table stored as users, and staging — where the migration actually created Users — breaks the moment anything queries lowercase. The inverse also bites: a dump created with mixed case on macOS deploys fine, then breaks under lower_case_table_names=0 only for queries that rely on folding.

The setting is also immutable after initialization on MySQL 8: you cannot flip it in my.cnf on an existing datadir; the server refuses to start. Plan accordingly.

fix preview — first 1 of 2 lines (sql), truncated:
SHOW VARIABLES LIKE 'lower_case_table_names'; … 1 more line in the fix

🔒 the fix — including 6 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.