centos中mysql密码忘记了怎么办

我只在centos中测试,其他没有测试
第一步:
修改/etc/my.cnf,在最后面加上
[mysqld]
skip-grant-tables
第二步,重启MySQL
systemctl restart mysqld
第三步:每一步都回车
1、mysql;
2、use mysql;
3、修改密码: update user set password=password('123456') where user='root';
如果出现
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
就用(5.7的)
update mysql.user set authentication_string=PASSWORD('123456') where user='root';
4、flush privileges;
第四步:
删掉/etc/my.cnf添加的内容
第五步:
重启mysql

用新密码登陆即可

找了很多,拼凑到一起才配置完成的

取消

感谢您的支持,我会继续努力哒!

扫码打赏
支付金额随意哦!

打开支付宝扫一扫,即可进行扫码打赏哦

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注