HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Username length restriction in different MySQL environments

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
lengthrestrictionusernamedifferentmysqlenvironments

Problem

I am setting up a project to my local environment and at its initial script are some SQL commands for creating the database:

  • create database 'db-name' default character set utf8;



and to grant privileges for the user account:

  • grant select, insert, update, delete, create, drop, index, alter on 'db-name'.* to 'user-name-too-long-for-user-name'@'localhost' identified by 'user-name-pass'



When I am trying to run the grant command I get this:

  • ERROR 1470 (HY000): String 'user-name-to-long-for-user-name' is too long for user name (should be no longer than 16)



and I can't understand why is this happening whereas this same script has successfully run to another environment before it comes to mine.

The server version I am using is 5.6.20 MySQL Community Server (GPL).

Is this situation related to a certain MySQL version or something else?

Solution

The maximum length for a user name in MySQL does depend on the version, as stated in the manual:


MySQL user names can be up to 32 characters long (16 characters before MySQL 5.7.8).

Context

StackExchange Database Administrators Q#147857, answer score: 17

Revisions (0)

No revisions yet.