Bug #100492 Create a clusteradmin account cannot specify hostname using mysql shell
Submitted: 11 Aug 2020 9:26 Modified: 10 Aug 2021 23:44
Reporter: Bin Hong (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Document Store: MySQL Shell Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[11 Aug 2020 9:26] Bin Hong
Description:
mysqlsh -- dba configureInstance root@localhost:8021 --clusterAdmin='mgradmin@192.%' --clusterAdminPassword='mgradmin'
Configuring local MySQL instance listening at port 8021 for use in an InnoDB cluster...

This instance reports its own address as single-8021:8021

The instance 'single-8021:8021' is valid to be used in an InnoDB cluster.

ERROR: Dba.configureInstance: single-8021:8021: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '% WITH GRANT OPTION' at line 1

How to repeat:
mysqlsh -- dba configureInstance root@localhost:8021 --clusterAdmin='mgradmin@192.%' --clusterAdminPassword='mgradmin'

Suggested fix:

Allowing any host to access is a security risk, and hope to support specifying the host when creating a user using the mysql shell
[11 Aug 2020 9:36] Bin Hong
If the clusteradmin parameter value contains ‘@’ use the host in the parameter, if it does not contain ‘@’ use % host
[11 Aug 2020 11:14] MySQL Verification Team
Hello Bin Hong,

Thank you for the feature request!

regards,
Umesh
[1 Mar 2021 23:31] Arvind Sharma
I wouldn't class this as a feature request. It's a bug if a MySQL user cannot be created where the username follows MySQL Account naming conventions - https://dev.mysql.com/doc/refman/8.0/en/account-names.html
[10 Aug 2021 23:44] Alfredo Kojima
This is not a bug. Hostnames that have % must be quoted separately, as is the case in MySQL in general:

$ mysqlsh -- dba configureInstance root@localhost --clusterAdmin="mgradmin@'192.%'" --clusterAdminPassword='mgradmin'
Configuring local MySQL instance listening at port 3306 for use in an InnoDB cluster...

...

Cluster admin user mgradmin@'192.%' created.
Configuring instance...
The instance 'localhost:3306' was configured to be used in an InnoDB cluster.
NOTE: MySQL server needs to be restarted for configuration changes to take effect.