Error
Error Code: 1360

MySQL Error 1360: Trigger Does Not Exist

📦 MySQL
📋

Description

This error indicates that MySQL cannot locate a trigger with the specified name when an operation attempts to reference it. It commonly occurs when trying to drop, alter, or create a trigger that doesn't exist in the current database or schema context.
💬

Error Message

Trigger does not exist
🔍

Known Causes

4 known causes
⚠️
Incorrect Trigger Name
The trigger name specified in the SQL statement contains a typo or does not exactly match the name of an existing trigger.
⚠️
Trigger Dropped or Never Created
The trigger was previously removed from the database, or it was never successfully created, making it unavailable for any operation.
⚠️
Wrong Database Context
The SQL statement is being executed while connected to a database or schema where the intended trigger does not reside.
⚠️
Case Sensitivity Mismatch
On systems configured for case-sensitive identifiers, the provided trigger name's casing does not match the actual trigger's casing.
🛠️

Solutions

3 solutions available

1. Verify Trigger Name and Schema easy

Ensure you are referencing the correct trigger name and that it exists in the current database schema.

1
List all triggers in the current database to confirm the trigger's existence and its exact name.
SHOW TRIGGERS;
2
If the trigger exists in a different database, explicitly qualify the trigger name with the database name.
SELECT * FROM your_database_name.your_table_name WHERE ...; -- Example of where a trigger might be invoked
3
Double-check the spelling of the trigger name in your query or application code.
DROP TRIGGER IF EXISTS your_trigger_name; -- Replace with your actual trigger name

2. Recreate the Missing Trigger medium

If the trigger is confirmed to be missing, recreate it using its original definition.

1
Identify the table associated with the missing trigger.
SHOW TRIGGERS LIKE 'your_trigger_name%'; -- Replace 'your_trigger_name%' with a pattern to find your trigger if you're unsure of the exact name
2
Retrieve the `CREATE TRIGGER` statement for the missing trigger. If you don't have it, you'll need to reconstruct it based on its intended functionality.
SHOW CREATE TRIGGER your_trigger_name; -- Replace with the actual trigger name
3
Execute the `CREATE TRIGGER` statement to recreate the trigger.
DELIMITER //
CREATE TRIGGER your_trigger_name
BEFORE INSERT ON your_table_name
FOR EACH ROW
BEGIN
    -- Your trigger logic here
END //
DELIMITER ;
-- Replace 'your_trigger_name', 'your_table_name', and the trigger logic with your specific details.

3. Check for Trigger Dropping or Disabling medium

Investigate if the trigger was intentionally or unintentionally dropped or disabled.

1
Review MySQL server logs (e.g., error log, general query log if enabled) for any `DROP TRIGGER` statements or other relevant activities around the time the error started occurring.
tail -f /var/log/mysql/error.log -- Or the path to your MySQL error log
2
If you have a version control system for your database schema, check its history for any changes that might have removed the trigger.
git log -- path/to/your/trigger_definition.sql
3
If the trigger was accidentally dropped, recreate it using the `CREATE TRIGGER` statement (see Solution 2).
See Solution 2 for recreating triggers.
🔗

Related Errors

5 related errors