我只在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
用新密码登陆即可
找了很多,拼凑到一起才配置完成的