1447
MariaDBERRORNotableViewsHIGH confidence

View definition references a user that does not exist

Production Risk

High — all queries against the view will fail until the definer is resolved.

What this means

ER_VIEW_FRM_NO_USER (1447, SQLSTATE HY000) is raised when a view stored on disk references a DEFINER user that no longer exists in the mysql.user table.

Why it happens
  1. 1The DEFINER user was dropped after the view was created
  2. 2Database was migrated and the definer account was not recreated
How to reproduce
trigger — this will error
trigger — this will error
-- After dropping the definer user:
DROP USER 'view_owner'@'localhost';
-- Querying the view now fails:
SELECT * FROM my_view;

expected output

ERROR 1447 (HY000): View 'db'.'my_view' references invalid user 'view_owner'@'localhost'

Fix

Recreate the definer user or redefine the view

Recreate the definer user or redefine the view
-- Option 1: Recreate the user
CREATE USER 'view_owner'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT ON my_db.* TO 'view_owner'@'localhost';

-- Option 2: Redefine the view with a valid definer
ALTER DEFINER = 'current_user'@'localhost'
VIEW my_view AS SELECT * FROM base_table;

Why this works

The DEFINER must exist as a valid MySQL user account for the view to function.

Sources
Official documentation ↗

MySQL 8.0 — 1447 ER_VIEW_FRM_NO_USER

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

← All MariaDB errors