mysqldude
Error codes › 1146

MySQL & MariaDB error 1146: Table doesn't exist

Error messageTable '….…' doesn't exist
Example from our test runs: Table 't_2.t1 WHERE 0 UNION SELECT s FROM secret' doesn't exist (5.6.51)

The statement names a table the server can't find in that database. A typo, the wrong database, letter case on Linux, or a table that really is missing (or whose files are damaged).

MySQLMariaDB
SymbolER_NO_SUCH_TABLEER_NO_SUCH_TABLE
SQLSTATE42S0242S02
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

The message gives the fully qualified name the server looked for: Table 'shop.order_items' doesn't exist. Check both halves: the table name and the database it was looked up in.

Why it happens

  • A typo, or the table is in another database (no USE, or the connection string names a different schema).
  • Letter case: on Linux the default lower_case_table_names = 0 makes table names case-sensitive, so Orders and orders are different tables. Code written on Windows or macOS (case-insensitive) breaks when moved to Linux.
  • The table was never created: a migration didn’t run, or a CREATE failed earlier in a script.
  • After copying data files by hand, InnoDB may know the table in its dictionary but not have the .ibd file, or the reverse. That also shows as 1146 (sometimes with 1932 “doesn’t exist in engine”).

How to fix it

  • SHOW TABLES; or SELECT table_schema, table_name FROM information_schema.TABLES WHERE table_name LIKE '%order%'; to find the real name and database.
  • Use the exact case, or qualify the name: SELECT … FROM shop.Orders.
  • lower_case_table_names can only be set when the data directory is initialised on MySQL 8.0, so pick it before creating databases if you need case-insensitive names on Linux.
  • For a table damaged by file copies, restore it from a logical backup (mysqldump) rather than copying files.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE Orders (id INT);
  2. Run:

    SELECT * FROM order_items;

You get: Table 't_0.order_items' doesn't exist(11.8.9)

Verified fixes

  1. List the tables and use the exact name, or qualify it with the database

    SELECT table_name FROM information_schema.TABLES WHERE table_schema = DATABASE();

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Query a table that isn't in the current database
repro
✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146
Same name, different letter case (lower_case_table_names=0 on Linux)
version check
✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146✓ 1146
List the tables and use the exact name, or qualify it with the database
fix
✓✓✓✓✓✓✓✓✓
Query a table that isn't in the current database repro
MySQL 5.6✓ 11465.7✓ 11468.0✓ 11468.4✓ 11469✓ 1146
MariaDB 10.6✓ 114610.11✓ 114611.4✓ 114611.8✓ 1146
Same name, different letter case (lower_case_table_names=0 on Linux) version check
MySQL 5.6✓ 11465.7✓ 11468.0✓ 11468.4✓ 11469✓ 1146
MariaDB 10.6✓ 114610.11✓ 114611.4✓ 114611.8✓ 1146
List the tables and use the exact name, or qualify it with the database fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1049 ER_BAD_DB_ERRORexplained
  • 1054 ER_BAD_FIELD_ERRORexplained
  • 1932 ER_NO_SUCH_TABLE_IN_ENGINE

Where this error shows up in our guides

  • Writing dynamic SQL in stored procedures · Quote the identifier with backticks; injection attempt now fails (1146) MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
  • Splitting fields · SELECT from tdata before calling the procedure (expect 1146) MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8