在Mysql 5.7中更新用户密码 [英] Update user password in Mysql 5.7
问题描述
我编写了一个安装脚本来使用以下SQL命令更改root密码:
UPDATE user SET password='*C563415623144561...' WHERE user='root';
这在Mysql 5.7上不起作用: 解决方案
从mysql 5.7开始,这不再是用户表中的密码字段.现在称为authentication_string.您可以像这样更改或设置密码:
set password for 'jeff'@'localhost' = PASSWORD('mypass'); // this automatically hashes the password
如果要使用查询,只需将password
更改为authentication_string
,即可使用.
UPDATE user SET authentication_string='*C563415623144561...' WHERE user='root@localhost';
希望获得帮助.
I wrote an installation script to change the root password with this SQL command:
UPDATE user SET password='*C563415623144561...' WHERE user='root';
This doesn't work on Mysql 5.7: http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html#mysqld-5-7-6-account-management
My question is: how to change this command with another one compatible with 5.6 and 5.7 version of Mysql? I would like to update the password with a hashed string and not with a clear password.
This is no more password field in the user table as of mysql 5.7. It's now called authentication_string. You can change or set the password like this:
set password for 'jeff'@'localhost' = PASSWORD('mypass'); // this automatically hashes the password
If you you want to use your query , just change password
to authentication_string
,and it will work.
UPDATE user SET authentication_string='*C563415623144561...' WHERE user='root@localhost';
Hope this help.
这篇关于在Mysql 5.7中更新用户密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!