MySQL Error 1146: Table Doesn't Exist
ERROR 1146 (42S02): Table 'myapp.user_sessions' doesn't exist
What is MySQL Error 1146?
MySQL Error 1146 occurs when a SQL statement references a table that does not exist in the current database. This is commonly caused by typos, wrong database selection, or missing database migrations.
Common Causes
- 1
Typo in the table name
- 2
Connected to the wrong database (USE wrong_database)
- 3
Table was deleted or never created (missing migration)
- 4
Case sensitivity issue on Linux — MySQL on Linux is case-sensitive by default
- 5
Table exists in a different schema/database than referenced
- 6
Temporary table expired (only exists for the session duration)
Step-by-Step Solutions
Verify the table exists: SHOW TABLES LIKE 'table_name';
Verify the correct database: SELECT DATABASE(); and USE correct_database;
Check for case sensitivity: SHOW TABLES; (exact casing must match on Linux)
Run pending database migrations if this is an application table
Check if table name has a typo: SHOW TABLES; lists all available tables
Prevention Tips
Always run database migrations before deploying application code
Use CI/CD pipeline checks to verify database schema before deployment
On Linux MySQL servers, set lower_case_table_names=1 to avoid case sensitivity issues
Use schema version management tools (Flyway, Liquibase) to track table creation
Frequently Asked Questions
Why is MySQL Error 1146 case-sensitive on Linux?
How do I check if a MySQL table exists?
Related Errors
Still Stuck?
Ask our AI SQL Assistant or the community — get answers in seconds.