1、mysql 啟動命令 :
mysql -uroot -p
2、mysql版本 查看命令:
select version();
image.png文章來源:http://www.zghlxwxcb.cn/news/detail-402867.html
3、查看用戶名對應(yīng)的host 命令 :
select user,host from user;
image.png
4、修改用戶的密碼:
alter user '用戶名'@'hostname' identified by 'newpwd';
---‘用戶名’是要修改的用戶名,hostname是user對應(yīng)的host,‘newpwd’是新密碼
image.png
修改用戶zp新密碼為1234
5、這個時候權(quán)限報錯
ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation
image.png
原因:MySQL8.0.16版本中新增了一個system_user帳戶類型,由于root用戶沒有SYSTEM_USER權(quán)限,把權(quán)限加入后即可解決。
grant system_user on?.?to 'root';
image.png
6、刷新權(quán)限
flush privileges;文章來源地址http://www.zghlxwxcb.cn/news/detail-402867.html
到了這里,關(guān)于mysql8.0更改用戶密碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!