SOLVED Username Length Limits

osirion

Well-Known Member
Jan 16, 2007
50
4
158
Hi Guys,
So cPanel used to have an 8 char limit on the usernames and this then got changed (to 16 characters I believe) - which is great. However, this brings another issue because MySQL usernames and database names were left at 16 characters.
This means if one creates a user with a long username, there is no space left for MySQL and then it just gives errors when trying to create users / db's.

I created a user recently, and cpanel automatically gave me a username based off the domain name (purpose of this demonstration, domain is 123456guestrooms.com and the username was 123456guestrooms).
I just got errors when trying to create MySQL users / db's and eventually figured this out - then just recreated the account with a smaller username (123456) and bob's your uncle - it worked.

So, in short:
Account username 16 char limit
MySQL username / database = 16 char limit
If account username = 16 char limit; then there are no characters left to create database users / database names.
Shouldn’t the account username limit be 14 characters so there is at least space for and under score and 1 character? Or, preferably, and from my understanding, MySQL now supports 32 characters so just update the mysql 16 character limit to 32?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
Hello @osirion,

I've been unable to reproduce the issue you described using the following steps:

1. Created an account cptest1234567890123.tld with username cptest1234567890.
2. Browsed to cPanel >> MySQL Databases and confirmed only the first eight characters of the username are utilized for the database prefix.
3. Attempted to create a second account using cptest12345678901234.tld with username cptest1234567891 and confirmed it was correctly forbidden with the following error message:

Account Creation Status: failed

(XID ae48uj) The name of another account on this server has the same initial 8 characters as the given username (cptest1234567891). Each username’s first 8 characters must be unique. at /usr/local/cpanel/Whostmgr/Accounts/Create.pm line 601.
Can you verify which version of cPanel & WHM is installed on your system, and which version of MySQL is installed?

Thank you.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,938
187
343
cPanel Access Level
Root Administrator
This is another classic example of a real head scratcher for me.

You can use a 16 character system username in cPanel... but the first 8 characters can't be shared with another system user. ... So... what's the point of having >8 character usernames? Never got a firm answer to that.

It is my understanding that MariaDB allows for longer database usernames. So this made sense if cPanel was moving towards MariaDB and would eventually drop the first 8 character uniqeueness requirement, but that never happened. And that was a long time ago. I'm not sure if cPanel is still moving towards MariaDB (they seem to be back to supporting MySQL as well - and perhaps newer versions of MySQL don't have this username restriction).

So yea, this was always a real head-scratcher for me. It was really fun explaining it to clients "No you can't use that username, even though that username is not used on the server, the first 8 characters of that username is used by another username."
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
Hello @sparek-3,

This limit is imposed because MySQL itself historically limited the database username to 16 characters. Thus, let's say cPanel usernames were permitted to share the first 15 characters and database prefixing was enabled. At that point, the likelihood of cPanel users encountering database user creation errors would increase significantly since MySQL doesn't permit duplicate database names or database usernames.

Since MariaDB limits the database username to 47 characters, the first eight characters of a username do not have to be unique when creating a cPanel account on a server using MariaDB.

With that said, a feature request to enable or disable the requirement for the first eight characters of the cPanel username to be unique isn't a bad idea, especially now that MySQL version 5.7 is offered and allows 32 characters:

Submit A Feature Request

Thank you.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,938
187
343
cPanel Access Level
Root Administrator
This limit is imposed because MySQL itself historically limited the database username to 16 characters. Thus, let's say cPanel usernames were permitted to share the first 15 characters and database prefixing was enabled. At that point, the likelihood of cPanel users encountering database user creation errors would increase significantly since MySQL doesn't permit duplicate database names or database usernames.
Yea, I get that... but this begs the question: Why did cPanel increase their username limit to 16 characters if you were still going to be hampered with the MySQL limit?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
Yea, I get that... but this begs the question: Why did cPanel increase their username limit to 16 characters if you were still going to be hampered with the MySQL limit?
The addition of the Require a username prefix on names of new databases and database users feature under the SQL tab in WHM >> Tweak Settings provided a way for server administrators to let cPanel users create databases and database usernames without the username prefix. Thus, a 16-character cPanel username wouldn't interfere with the ability to create MySQL users and databases.

Thank you.
 

sparek-3

Well-Known Member
Aug 10, 2002
1,938
187
343
cPanel Access Level
Root Administrator
And that was a well thought out idea because... ?

Someone's going to create a database username of wordpress and then someone else is going to wonder why they can't use wordpress as their database username.

In my humble opinion, this was all an exercise in cPanel trying too hard. Somebody wanted a longer username and instead of telling them no and explaining why, you caved and added that functionality into the system when the system just wasn't ready for it.

It's all water under the bridge now. But it's also a learning experience. You don't have to cave in to every little feature request. It's a whole lot easier to say no when a feature isn't ready than spending resources with every new version trying to fix the usability of an ill-advised feature.
 

osirion

Well-Known Member
Jan 16, 2007
50
4
158
Ok, I think we're getting off track here with the original issue at hand :P

@cPanelMichael - I'm using v70.0.48 of cPanel and Currently installed: 10.0.35-MariaDB

It happened with two users so it wasnt a once off. With the one user, I removed him and re-added with a smaller username. with the second user, the username was small enough to at least have an underscore and 2 characters - so I went with that.
Should I open a ticket for you to investigate further?

Error log still showing the errors from the failed Wordpress installs because of the above mentioned reason; but worked when I ended up setting up the db's and users manually and then doing a manual install of WP
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
Hello @osirion,

Yes, please open a support ticket so we can take a closer look at what you are describing. You can post the ticket number here once it's opened.

Thank you.
 

osirion

Well-Known Member
Jan 16, 2007
50
4
158
@cPanelMichael - Ticket created: 9720675
Just remember that as per the ticket, the best example of this is stated in the ticket, but I deleted said user and created it again with a smaller username.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
Hello,

To update, it looks like the update from MySQL 5.6 to MariaDB 10.0 did not finish successfully on the affected system system. The mysql_upgrade command did not run cleanly, and thus the username limit defined in the mysql.user table still showed 16 characters. Upon successfully running the mysql_upgrade command on the affected system, the username limit was updated to the MariaDB limit of 80 characters.

Thank you.