Common SQL Errors

MySQL Error 1602: ER_TRG_CORRUPTED_FILE - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>MySQL error 1602 (ER_TRG_CORRUPTED_FILE) appears when the server detects a damaged .TRG metadata file that stores trigger definitions for a table.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1602?

<p>MySQL Error 1602: ER_TRG_CORRUPTED_FILE occurs when a table’s .TRG metadata file is unreadable or inconsistent. Restore the trigger definition by dropping and recreating the trigger or by replacing the corrupted .TRG file with a clean backup to resolve the issue.</p>

Error Highlights

Typical Error Message

Corrupted TRG file for table `%s`.`%s`

Error Type

Trigger Error

Language

MySQL

Symbol

ER_TRG_CORRUPTED_FILE

Error Code

1602

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1602 (ER_TRG_CORRUPTED_FILE)?

Error 1602 signals that MySQL failed to parse the .TRG file holding trigger metadata for a specific table. The server marks the trigger as unusable and blocks DML that relies on it.

Because .TRG files live in the table’s data directory, file-system corruption, interrupted writes, or manual edits can break their internal XML-like structure, leading to this error during startup or any operation that loads triggers.

What Causes This Error?

File-system corruption or unexpected shutdowns can truncate or zero-out .TRG files, leaving invalid markup that MySQL cannot read.

Manual copying of table files between servers without FLUSH TABLES WITH READ LOCK often skips associated .TRG files, causing version mismatches and corruption warnings.

Upgrades or downgrades that change trigger file format can break compatibility if the server reads older files without running mysql_upgrade.

How to Fix MySQL Error 1602

Identify the corrupted .TRG file by reading the error log entry that names the table. Backup the table directory before any changes.

The fastest fix is to drop and recreate each affected trigger, which forces MySQL to generate a fresh .TRG file with correct metadata.

If the trigger definition is lost, recover it from a schema backup, mysqldump file, or the information_schema.triggers table on another replica.

Common Scenarios and Solutions

During server startup, error 1602 can prevent the instance from serving traffic. Start MySQL with --skip-grant-tables, rename the corrupted .TRG file, then recreate triggers once the server is online.

When cloning data directories between environments, copy .TRG files along with .frm and .ibd files, or run mysqldump --triggers to keep metadata intact.

Best Practices to Avoid This Error

Use logical backups such as mysqldump or mysqlpump with --triggers to ensure portable trigger definitions.

Enable crash-safe settings like innodb_flush_log_at_trx_commit = 1 and sync_binlog = 1 to minimize file damage on power loss.

Version-control your trigger DDL in Git and regenerate triggers after deployments with an automated migration tool such as Flyway or Liquibase.

Related Errors and Solutions

Error 1532 ER_TRG_NO_DEFINER indicates missing DEFINER information in the .TRG file; recreate the trigger with a valid DEFINER to solve it.

Error 1146 ER_NO_SUCH_TABLE appears if the .TRG file references a table that no longer exists; remove the trigger or create the missing table.

Common Causes

Crash or power failure

Sudden shutdown can interrupt disk writes, leaving partial data in the .TRG file.

Manual file edits

Opening and saving .TRG files in a text editor may introduce invalid characters or encoding changes.

Inconsistent backups

Physical backups taken without locking tables might copy data files but skip associated .TRG files.

Version mismatch after upgrade

Running a new MySQL version on old data files without mysql_upgrade can break trigger metadata compatibility.

Related Errors

MySQL Error 1532: ER_TRG_NO_DEFINER

Raised when the DEFINER user in the .TRG file does not exist. Recreate the trigger with a valid DEFINER.

MySQL Error 1530: ER_TRG_INVALID_CREATION_CTX

Occurs if the trigger creation context is invalid. Ensure the character set and collation of the database match those stored in the .TRG file.

MySQL Error 1146: ER_NO_SUCH_TABLE

Appears when a trigger references a table that has been dropped. Remove or update affected triggers.

FAQs

How do I know which .TRG file is corrupted?

Check the MySQL error log; it prints the schema and table name whose TRG file failed to load.

Can I repair a .TRG file without dropping the trigger?

In most cases, no. Recreating the trigger is safer than editing the XML inside the .TRG file.

Does mysqldump include triggers by default?

Yes, mysqldump exports triggers unless --skip-triggers is used. Always keep triggers in backups.

How can Galaxy help prevent this error?

Galaxy versions all trigger creation scripts in shared collections, letting teams quickly redeploy valid DDL to replace corrupted .TRG files.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo