1677
MariaDBERRORNotableInnoDBHIGH confidence

Tablespace already exists

Production Risk

Medium — the CREATE is rejected; existing tablespace is unaffected.

What this means

An InnoDB tablespace with the specified name already exists, typically when trying to create a general tablespace that was already created or when an orphaned .ibd file conflicts with a CREATE TABLE.

Why it happens
  1. 1CREATE TABLESPACE was called for a tablespace that already exists.
  2. 2An orphaned .ibd file from a previous table exists in the data directory.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB;
-- When ts1 already exists

expected output

ERROR 1677 (HY000): InnoDB: Tablespace 'ts1' already exists.

Fix 1

Drop the existing tablespace first if it is unused

Drop the existing tablespace first if it is unused
DROP TABLESPACE ts1;
CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB;

Why this works

Dropping the conflicting tablespace allows the new one to be created.

Fix 2

Remove orphaned .ibd files

Remove orphaned .ibd files
-- Stop MySQL, remove the orphaned .ibd file, restart MySQL

Why this works

Orphaned files left from incomplete DROP TABLE can prevent new table creation.

Sources
Official documentation ↗

MySQL 8.0 — 1677 ER_TABLESPACE_EXISTS

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors