ERROR 1146 (42S02): Table 'database.table' doesn't exist
ERROR 1146 (42S02): Table 'database.table' doesn't exist
DodaTech
2 min read
The error “ERROR 1146 (42S02): Table ‘database.table’ doesn’t exist” means MySQL could not find a table with the specified name in the given database.
What It Means
MySQL’s storage engine searched for the table in the table metadata. The table name either does not exist in the specified database, the database itself does not exist, or the table name was used in a context that resolved to the wrong location.
Why It Happens
- The table was never created.
- You connected to the wrong database — the table exists in
db1but you are querying indb2. - The table name is case-sensitive on case-sensitive file systems (Linux) —
Usersis different fromusers. - The table was accidentally dropped or the database was recreated without restoring.
- A migration or schema script failed partway through, leaving the database without some tables.
- The table exists but you are not using the fully qualified name and the default database is wrong.
How to Fix It
1. List tables in the current database
USE database_name;
SHOW TABLES;2. Check for the table using a fully qualified name
SELECT * FROM database_name.table_name LIMIT 1;3. Check the database name and connection
mysql -u user -p -D database_name
SHOW DATABASES;4. Recreate the table from schema
SOURCE /path/to/schema.sql;5. Restore from backup
mysql -u user -p database_name < backup.sqlFAQ
Previous
ERROR 1045 (28000): Access denied for user
Next
fatal: not a git repository (or any of the parent directories): .git
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro