Home > Database > Mysql Tutorial > Why Does MySQL Show \'Tablespace for Table Exists. Please DISCARD before IMPORT\' Even After Dropping the Tablespace?

Why Does MySQL Show \'Tablespace for Table Exists. Please DISCARD before IMPORT\' Even After Dropping the Tablespace?

Barbara Streisand
Release: 2024-12-06 00:42:10
Original
301 people have browsed it

Why Does MySQL Show

MySQL Error: "Tablespace for Table Exists. Please DISCARD before IMPORT"

Question:

When trying to recreate a table that was accidentally deleted, users encounter the error "Tablespace for table 'database.temp' exists. Please DISCARD the tablespace before IMPORT." Despite attempting to drop or discard the tablespace, the error persists, indicating that the table no longer exists.

Answer:

This issue often arises due to a 'tablespace full' error in 'innodb_file_per_table' mode.

  • Identifying the Orphaned File:

Check the directory where the tablespaced tables are stored (e.g., /usr/local/var/mysql) for an orphaned .ibd file (e.g., table3.ibd) without its usual .frm counterpart (table3.frm).

  • Resolution:

Move the orphaned .ibd file to a temporary location:

mkdir /tmp/mysql_orphans
mv /usr/local/var/mysql/table3.ibd /tmp/mysql_orphans/
Copy after login
  • Caution:

Ensure that the underlying cause (e.g., long-running query, locked table) has been resolved to prevent further orphaned files.

The above is the detailed content of Why Does MySQL Show \'Tablespace for Table Exists. Please DISCARD before IMPORT\' Even After Dropping the Tablespace?. 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