Error
Error Code:
1146
MySQL Error 1146: Table Not Found
Description
This error indicates that MySQL cannot find the specified table in the current database context. It typically occurs when an SQL query references a table name that does not exist, is misspelled, or is in a different database.
Error Message
Table '%s.%s' doesn't exist
Known Causes
4 known causesIncorrect Table Name
The table name specified in your SQL query contains a typo or does not exactly match the actual table name in the database.
Table Does Not Exist
The table you are trying to access has not been created in the database or has been dropped previously.
Wrong Database Selected
Your query is being executed in the context of a different database where the target table does not exist.
Case Sensitivity Mismatch
On some operating systems (like Linux), MySQL table names are case-sensitive, and your query might be using incorrect casing.
Solutions
5 solutions available1. Verify Table Name Spelling easy
Check for typos in table name
1
List all tables in current database
SHOW TABLES;
2
Search for similar table names
SHOW TABLES LIKE '%user%';
3
Check table existence
SELECT TABLE_NAME FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'your_database' AND TABLE_NAME = 'users';
2. Check Database Context easy
Make sure you're in the right database
1
Check current database
SELECT DATABASE();
2
Switch to correct database
USE correct_database_name;
3
Or use fully qualified table name
SELECT * FROM database_name.table_name;
3. Fix Case Sensitivity Issues medium
Table names may be case-sensitive on Linux
1
Check lower_case_table_names setting
SHOW VARIABLES LIKE 'lower_case_table_names';
2
List tables to see exact case
SHOW TABLES;
3
Use exact case in query
-- If table is 'Users' not 'users':
SELECT * FROM Users;
4. Create Missing Table medium
Create the table if it should exist
1
Create the table with appropriate structure
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
name VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
2
Or restore from backup if table was dropped
mysql -u username -p database_name < backup.sql
5. Check for Temporary Table Issues medium
Temporary tables only exist in current session
1
Note: Temporary tables are session-specific
-- If created in another session, it won't be visible
CREATE TEMPORARY TABLE temp_results (
id INT,
value VARCHAR(100)
);
2
Convert to permanent table if needed
CREATE TABLE permanent_results AS
SELECT * FROM temp_results;