1 use mysql
2 查看用戶信息
select host, user, authentication_string, plugin from user;
注意:該命令可以查看root用戶對應(yīng)及其他用戶的信息
3 設(shè)置或更新密碼
update user set authentication_string='newpassword' where user='root';
注意
8.0版本之后MySQL的password函數(shù)設(shè)置密碼已經(jīng)被取消,所以,
update mysql.user set password='newpassword' where user='root';
update mysql.user set password=PASSWORD('newpassword') where User='root';
這兩條命令已經(jīng)不起作用了。
4 刷新
flush privileges;