有时候就会遇到这种尴尬的情况,密码给忘了
所以
1 修改 /etc/my.cnf
[mysqld] 下
添加
skip-grant-tables
2 systemctl restart mysqld
3 mysql
进入
use mysql;
update user set password=password("new_passwd") where user="root";
//
有时候会遇到
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
因为错误的原因是 5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string
update mysql.user set authentication_string=password('*******') where user='*******';
//
flush privileges;
ctrl d
4 再去掉前面添加的/etc/my.cnf
5 systemctl restart mysqld