Change mysql user password using command line

前端 未结 9 1445
小鲜肉
小鲜肉 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:35

    As of MySQL 5.7.6, use ALTER USER

    Example:

    ALTER USER 'username' IDENTIFIED BY 'password';
    

    Because:

    • SET PASSWORD ... = PASSWORD('auth_string') syntax is deprecated as of MySQL 5.7.6 and will be removed in a future MySQL release.

    • SET PASSWORD ... = 'auth_string' syntax is not deprecated, but ALTER USER is now the preferred statement for assigning passwords.

提交回复
热议问题