2029
MariaDBERRORNotableAccess ControlHIGH confidence

Invalid hostname or username in GRANT

Production Risk

Low — GRANT is rejected.

What this means

The username or hostname specified in a GRANT statement is syntactically invalid or exceeds the maximum length. Usernames are limited to 32 characters (MySQL 5.7+) and hostnames to 255 characters.

Why it happens
  1. 1Username exceeds the maximum length (32 characters in MySQL 5.7+, 16 in older versions).
  2. 2Invalid characters in the hostname portion.
  3. 3Malformed host wildcard pattern.
How to reproduce
trigger — this will error
trigger — this will error
GRANT SELECT ON *.* TO 'this_username_is_way_too_long_for_mysql'@'%';

expected output

ERROR 2029 (HY000): The host or user argument to GRANT is too long.

Fix

Shorten the username to 32 characters or fewer

Shorten the username to 32 characters or fewer
GRANT SELECT ON *.* TO 'short_name'@'%';

Why this works

MySQL enforces a maximum username length at the grant level.

What not to do

Version notes

Sources
Official documentation ↗

MySQL 8.0 — 2029 ER_GRANT_WRONG_HOST_OR_USER

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

← All MariaDB errors