1945
MariaDBERRORNotableSecurityHIGH confidence

Malformed DEFINER clause

Production Risk

Low — object creation is rejected; fix the DEFINER clause.

What this means

The DEFINER clause in a CREATE VIEW, FUNCTION, PROCEDURE, TRIGGER, or EVENT statement is not in the required user@host format, or references an invalid account.

Why it happens
  1. 1DEFINER specified without a host part: DEFINER = 'root' instead of DEFINER = 'root'@'localhost'.
  2. 2Invalid characters in the username or hostname portion of the definer.
How to reproduce
trigger — this will error
trigger — this will error
CREATE DEFINER='root' VIEW v AS SELECT 1;

expected output

ERROR 1945 (HY000): Malformed definer 'root'.

Fix

Use the fully qualified user@host format

Use the fully qualified user@host format
CREATE DEFINER='root'@'localhost' VIEW v AS SELECT 1;

Why this works

MySQL requires the DEFINER to specify both user and host parts.

Sources
Official documentation ↗

MySQL 8.0 — 1945 ER_MALFORMED_DEFINER

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

← All MariaDB errors