在Mysql 5.7中更新用户密码 [英] Update user password in Mysql 5.7

查看:383
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆