--方法1
alter user 'root'@'localhost' identified by 'your password';
--方法2,需要已知password
mysqladmin -uroot -pold_password password net_password
--错误,user表中已经没有password字段
use mysql;
update user set password='pwd' where user='root';
--authentication_string不是密码字段
update mysql.user set authentication_string=password('root') where user='root';
--上句执行后警告,password()以后将移除
show warnings;
--'PASSWORD' is deprecated and will be removed in a future release.
mysql(5.7.17)修改密码
最新推荐文章于 2024-08-17 02:56:46 发布
本文提供了两种重置MySQL root用户密码的方法:使用SQL命令直接修改和利用mysqladmin工具进行更新。文章强调了password()函数及authentication_string字段的正确用法,并提醒读者注意已被废弃的password字段。
229

被折叠的 条评论
为什么被折叠?



