mysql8.0更改用户密码
2022-10-11 本文已影响0人
白马书院
1、mysql 启动命令 :
mysql -uroot -p
2、mysql版本 查看命令:
select version();

3、查看用户名对应的host 命令 :
select user,host from user;

4、修改用户的密码:
alter user '用户名'@'hostname' identified by 'newpwd';
---‘用户名’是要修改的用户名,hostname是user对应的host,‘newpwd’是新密码

修改用户zp新密码为1234
5、这个时候权限报错
ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation

原因:MySQL8.0.16版本中新增了一个system_user帐户类型,由于root用户没有SYSTEM_USER权限,把权限加入后即可解决。
grant system_user on . to 'root';

6、刷新权限
flush privileges;