"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Does My MySQL Table Appear in SHOW TABLES But Not in SELECT Queries?

Why Does My MySQL Table Appear in SHOW TABLES But Not in SELECT Queries?

Published on 2025-02-03
Browse:565

Why Does My MySQL Table Appear in SHOW TABLES But Not in SELECT Queries?

MySQL Table Disappearance Conundrum Resolved

When experiencing an inconsistency where SHOW TABLES displays a table that is inaccessible for data operations, such as SELECT, the underlying cause often remains elusive. One potential culprit is a corrupted table file, which may be undetected by SHOW TABLES.

In one particular instance, a user encountered this issue after changing the MySQL data directory. Despite the table's files being present, selecting data from it resulted in the error:

ERROR 1146 (42S02): Table 'database.TABLE_ONE' doesn't exist

This paradoxical behavior led to speculation that SHOW TABLES only verifies file existence, not integrity. However, the root of the problem was eventually discovered:

  • The database in question used InnoDB tables, which rely on the ibdata1 and ib_logfile files stored in the MySQL data directory.
  • These files were not present in the new data directory when the database was moved.

To resolve the issue, the user copied these files into the new data directory, which successfully restored table accessibility. This underscores the importance of including these files when copying InnoDB-based databases to ensure their functionality.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3