在/etc/my.cny中;
在[mysqld]下面添加一条命令:
skip-grant-tables
在到linux上进入mysql界面:
mysql -u root -p
在进入mysql数据库中:
现在输入这条sql,
update user set password=password(“填入新密码”) where user=‘root’;
如有报错:
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
原因:
是从mysql 5.7开始,password字段被替换为了authentication_string
修改:
update user set authentication_string=password('填入新密码”') where user='root';
刷新mysql权限:
flush privileges;
退出:exit;
推出后,在此进入/etc/my.cny文件中:
删除:skip-grant-tables
操作完后,保存即可,再次进入查看是否设置正确。