MySQL5.7已经没有password这个字段了,改成了authentication_string
update mysql.user set authentication_string=password('root') where user='root' ;
完整的更改MySQL密码的方式如下:
1.vim /etc/my.cnf [mysqld]段增加skip-grant-tables
2./etc/init.d/mysqld restart
3.终端输入mysql 直接登录MySQL数据库,然后use mysql
4.update mysql.user set authentication_string=password('root') where user='root' ;
5.flush privileges; #立即生效
6.quit;
7.编辑/etc/my.cnf 删掉skip-grant-tables, 然后重启MySQL /etc/init.d/mysqld restart
8.mysql -u root -p 然后输入密码即可登录MySQL数据库
旧版改密码的命令如下,MySQL5.7 password改成了authentication_string
mysql> update user set password=password(“新密码”) where user=”用户名”;
本文详细介绍了在MySQL5.7中如何修改用户密码,包括使用authentication_string字段替代旧版password字段的方法,以及通过配置文件跳过权限表检查来临时登录数据库进行密码更新的具体步骤。
2万+

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



