mysql5.7就需要初始密码
cat /var/log/mysqld.log | grep password
重置密码的第一步就是跳过MySQL的密码认证过程
查找my.cnf文件的位置
find -name my.cnf
我的文件位置是 ./etc/my.cnf
打开my.cnf文件
vim /etc/my.cnf
找到[mysqld],在它的后面任意下一行添加如下代码
skip-grant-tables
然后重启mysql
1.use mysql;(使用mysql数据库)
2.update user set password=password("你的密码") where user="root";
或update user set authentication_string=password('新密码') where user='root' and Host='localhost';
3.flush privileges;
4.quit
注释掉刚才my.cnf的配置
systemctr restart mysqld
文章介绍了在MySQL5.7版本中如何查看初始密码,以及在忘记密码时如何跳过密码认证重置root用户的密码。关键步骤包括编辑my.cnf文件添加skip-grant-tables,更新用户密码,然后重启MySQL服务。
2013

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



