Suggestion: change CREATE USER to be implemented with GRANT

  • By reviewing the code to implement multiple servers i noticed some warnings of users that could not be created ( because they already existed )


    In all the install codes you added a piece of code to always try to create a user. Now a better solution ( also widely accepted with mysql and mariadb ) is to add a IDENTIFIED BY inside de GRANT function.


    Example of a change i made in my fork:
    https://github.com/GuardMoony/…e815859dd82819da4a04e7a06

  • @GuardMoony


    You're wrong. The code first checks if the user has been already created. If you get a warning, this is surely due to some changes you have made in your fork. Whatever. Please don't report us all changes you made in your fork. We have no interest for them.


    Perl
    1. unless("$dbUser\@$dbUserHost" ~~ @main::createdSqlUsers)


    Here, the SQL user is created unless already in the @main::createdSqlUsers list which old users that were already created. We could improve the code but not in 1.2.x.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @GuardMoony


    Anyway: http://dev.mysql.com/doc/refman/5.7/en/grant.html :

    Code
    1. However, use of GRANT to create accounts or define nonprivilege characteristics is deprecated as of MySQL CREATE USER or ALTER USER.


    Furthermore, starting with MySQL >= 5.7.6, we will use thepassword_option provided by CREATE USER to set password expiration which is not available in GRANT statement ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @GuardMoony



    Furthermore, starting with MySQL >= 5.7.6, we will use thepassword_option provided by CREATE USER to set password expiration which is not available in GRANT statement ;)

    Thx for the info.


    May i then suggest making use of IF NOT EXISTS like subscribed in the CREATE USER article provided by you? and combine it with ALTER USER if it exists

  • @GuardMoony


    I must first check if the [IF NOT EXISTS] is available in all supported SQL server versions (MySQL, percona, mariadb). Also, ALTER USER is not available in older versions.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206