Updated: 11 October 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
Very old MySQL versions (5.6 and earlier) allowed user names of at most 16 characters; longer names failed to log in. Current versions allow longer names:
- MariaDB (default on AlmaLinux, Rocky, Ubuntu and Debian): up to 80 characters.
- MySQL 5.7.8 and later, including 8.x: up to 32 characters.
If a login fails because of the name
- Check the server version:
mariadb --versionorSELECT VERSION();. - List the existing accounts and compare the exact name:
SELECT User, Host FROM mysql.user;. - If the name is too long for the server, create a shorter one and give it the same rights:
CREATE USER 'shopapp'@'localhost' IDENTIFIED BY '…'; GRANT ALL ON shopdb.* TO 'shopapp'@'localhost'; - Update the application's configuration file with the new user name.
On cPanel hosting, database user names start with your account prefix (for example cpuser_), which counts towards the limit. Keep the part you choose short.
Other causes of the same "access denied" error are a wrong password, a user created for localhost while the application connects to 127.0.0.1 or another host, or a user without rights on the database. SHOW GRANTS for the account shows what it may do.