修改 /etc/my.cnf
添加
skip-grant-tables
修改完后重启mysql
这样就可以直接进入mysql
然后修改mysql数据库密码
mysql>update user set password=password("123456") where user="root";
修改完以后 在注释掉 skip-grant-tables