Mysql user creation script

后端 未结 7 662
猫巷女王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:11

    If you do not want to store password in clear text, then save it in hashed format -

    GRANT ALL PRIVILEGES ON mytestdatabase.* TO 'mytestdatabase'@'localhost'
      IDENTIFIED BY PASSWORD '*7560636C2922C05954FE6A2446AA00C84708B57B';
    

    Where hashed password is a result of this query -

    SELECT PASSWORD('my password');
    
    0 讨论(0)
  • 2021-02-02 10:14

    I have also got same problem, it is resolved just by setting the password by mentioned query below.

    SET PASSWORD FOR 'user'@'localhost' = PASSWORD('MyNewPass');

    0 讨论(0)
  • 2021-02-02 10:24

    Well hat is error bcoz you have wrote the wrong way just you have wrote,

    GRANT ALL PRIVILEGES ON *.* TO 'USER'@'localhost' IDENTIFIED BY PASSWORD '@password';
    

    and the true syntax is follows. look here.

    GRANT ALL PRIVILEGES ON *.* TO 'USER'@'localhost' IDENTIFIED BY '@password';
    

    because your password is causing that error. it must be in as shown.

    0 讨论(0)
  • 2021-02-02 10:25

    Take a look at the following url and this will help you to fix the issue:

    http://linuxadministrator.pro/blog/?p=147

    mysql> select password('12345');
    +-------------------------+
    | password('123456') |
    +-------------------------+
    | 2ff898e158cd0311        |
    +-------------------------+
    1 row in set (0.00 sec)
    
    mysql> create user test identified by password '2ff898e158cd0311';
    Query OK, 0 rows affected (0.00 sec)
    
    0 讨论(0)
  • 2021-02-02 10:28

    try:

    GRANT ALL PRIVILEGES ON mytestdatabase.* 
          TO mytestdatabase@localhost IDENTIFIED BY 'PASSWORD';
    

    where PASSWORD is your password (in quotes).

    0 讨论(0)
  • 2021-02-02 10:29

    I opened phpMYAdmin and went to the the users tab, found the user i was trying to connect with clicked Edit Privileges, scrolled down to the Change Login Information / Copy User section and choose Any host for the Host option, it was set to local. When I clicked the Go button, it generated a script similar to the ones listed here.

    GRANT ALL PRIVILEGES ON * . * TO 'james'@'%' IDENTIFIED BY PASSWORD '*780E1D13F1C7713F341A117499C6D8644464C4CF' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
    
    0 讨论(0)
提交回复
热议问题