mysql8.0 change user password

1. Mysql startup command:
mysql -uroot -p
2. Mysql version check command:
select version();

image.png

3. View the host command corresponding to the user name:
select user,host from user;

image.png

4. Modify the user's password:
alter user 'username'@'hostname' identified by 'newpwd';
---'username' is the username to be modified, hostname is the host corresponding to the user, and 'newpwd' is the new password

image.png

Modify the new password of user zp to 1234

5. At this time, the permission error is reported
ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation

image.png


Reason: A system_user account type is added in MySQL8.0.16 version. Since the root user does not have the SYSTEM_USER authority, the solution can be solved after adding the authority.
grant system_user on  .  to 'root';

image.png

6. Refresh privileges
flush privileges;

Guess you like

Origin blog.csdn.net/sunzongpeng/article/details/127257723