Home > Database > Mysql Tutorial > 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?

Mary-Kate Olsen
Release: 2024-12-07 05:49:12
Original
759 people have browsed it

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
Copy after login

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.

The above is the detailed content of Why Does My MySQL Table Appear in SHOW TABLES But Not in SELECT Queries?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template