Mysql user creation script

后端 未结 7 663
猫巷女王i
猫巷女王i 2021-02-02 10:00

I\'m trying to automate MySQL user creation procedure. I thought of creating a temp file that would contain mysql user creation statements, then I would have call it like this :

相关标签:
7条回答
  • 2021-02-02 10:33

    Just to answer why the error occurs and to show the differnce:


    A) Expects @password to be a hash string 1 value:

    GRANT ALL PRIVILEGES 
        ON `mydb` . * TO 'username'@'localhost' IDENTIFIED 
    BY
    PASSWORD '@password';
    

    Note the use of the PASSWORD keyword!


    B) Expects @password to be a clear-text string value:

    GRANT ALL PRIVILEGES 
        ON `mydb` . * TO 'username'@'localhost' IDENTIFIED 
    BY
    '@password';
    

    Note the missing PASSWORD keyword!


    1 Where "hash string" is the result of SELECT PASSWORD('clearTextPasswd'); - see Snowman's answer for an example.

    0 讨论(0)
提交回复
热议问题