Home > Database > Mysql Tutorial > body text

Why Can\'t I Drop a MySQL Table That \'Already Exists\'?

DDD
Release: 2024-10-27 03:37:02
Original
669 people have browsed it

 Why Can't I Drop a MySQL Table That

MySQL Table Enigma: Existing Yet Nonexistent

Facing the paradoxical error of "table already exists" during table creation or alteration, yet encountering "unknown table" during drop attempts, users have been left puzzled and unable to resolve the issue.

Investigating the Anomaly

Examination of the database reveals an absence of the table in 'show tables,' and 'describe' reports that the table doesn't exist. Surprisingly, no .frm file can be found, and attempts to create the table using "create table if not exists" fail. To make matters worse, dropping the database results in MySQL crashes.

Possible Resolution

After analyzing various unsuccessful attempts, the underlying cause seems to reside in missing table files. In the data directory, an orphaned .frm file without the corresponding data file, or vice versa, can cause this issue. If using innodb_file_per_table, ensure both .frm and .ibd files exist for the affected table. For MYISAM, the expected files are .frm, .MYI, and .MYD.

Resolving the Enigma

To resolve the issue, manually delete the orphaned file from the data directory. This should allow successful creation or deletion of the affected table and resolve the database crashing problem.

The above is the detailed content of Why Can\'t I Drop a MySQL Table That \'Already Exists\'?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!