3386
MySQLERRORNotableAccess ControlHIGH confidence
Role already exists
Production Risk
Low — CREATE ROLE fails; no role is created.
How to reproduce
trigger — this will error
trigger — this will error
CREATE ROLE my_role; CREATE ROLE my_role;
expected output
ERROR 3386 (HY000): Role 'my_role'@'%' already exists.
Fix
Use IF NOT EXISTS
Use IF NOT EXISTS
CREATE ROLE IF NOT EXISTS my_role;
Why this works
IF NOT EXISTS suppresses the error and makes the statement idempotent.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3386 ER_ROLE_ALREADY_EXISTS
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev