// MySQL error reference

MySQL error 1146: Table doesn't exist

MySQL can't find the table in the named or current database. Check the database, the spelling and, on Linux, the letter case of the name.

Error number
1146
Name
ER_NO_SUCH_TABLE
SQLSTATE
42S02
Category
Databases, tables and columns
Error message
Table '%s.%s' doesn't exist

What it means

The message shows the database and table MySQL looked for: Table 'shop.orders' doesn't exist. That tells you which database it searched, which is often the real problem.

Whether table names are case-sensitive depends on lower_case_table_names: by default they are on Linux and not on Windows or macOS, so code that works on a laptop can fail with 1146 on a Linux server.

Common causes

  • Connected to a different database than the one holding the table.
  • A typo, or a different letter case on a Linux server.
  • The table hasn't been created yet: a migration didn't run, or a restore is incomplete.
  • An InnoDB table whose data dictionary entry exists but whose .ibd file is missing or damaged (the server error log will say so).

How to fix it

  1. Check which database you're in and what tables it has.

    SELECT DATABASE();
    SHOW TABLES LIKE '%order%';
  2. Search every database for the table.

    SELECT table_schema, table_name
    FROM information_schema.tables
    WHERE LOWER(table_name) = 'orders';
  3. Qualify the name with the database, or USE the right one.

    SELECT * FROM shop.orders LIMIT 10;

Reproduce it safely

SELECT * FROM no_such_table;  -- ERROR 1146 (42S02): Table 'db.no_such_table' doesn't exist

Related errors

More databases, tables and columns errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.