Change mysql user password using command line

前端 未结 9 1436
小鲜肉
小鲜肉 2021-01-31 06:49

I\'m trying to update the password for a database user using the command line, and it\'s not working for me. This is the code I\'m using:

mysql> UPDATE user S         


        
相关标签:
9条回答
  • 2021-01-31 07:16

    Before MySQL 5.7.6 this works from the command line:

    mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$w0rdf1sh');"
    

    I don't have a mysql install to test on but I think in your case it would be

    mysql -e "UPDATE mysql.user SET Password=PASSWORD('$w0rdf1sh') WHERE User='tate256';"
    
    0 讨论(0)
  • 2021-01-31 07:19

    This works for me. Got solution from MYSQL webpage

    In MySQL run below queries:

    FLUSH PRIVILEGES;
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'New_Password';
    
    0 讨论(0)
  • 2021-01-31 07:23

    In windows 10, just exit out of current login and run this on command line

    --> mysqladmin -u root password “newpassword”

    where instead of root could be any user.

    0 讨论(0)
  • 2021-01-31 07:23

    As of MySQL 8.0.18 This works fine for me

    mysql> SET PASSWORD FOR 'user'@'localhost' = 'userpassword';

    0 讨论(0)
  • 2021-01-31 07:27

    Note: u should login as root user

     SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your password');
    
    0 讨论(0)
  • 2021-01-31 07:27

    this is the updated answer for WAMP v3.0.6

    UPDATE mysql.user 
    SET authentication_string=PASSWORD('MyNewPass') 
    WHERE user='root';
    
    FLUSH PRIVILEGES;
    
    0 讨论(0)
提交回复
热议问题