1.在/etc/my.cnf中添加配置 免密码登陆
skip-grant-tables
2.进行免密码登陆(mysql指令位于mysql安装目录的bin/)
mysql -u root
3.重置密码
use mysql;
update mysql.user set authentication_string=password('root_password') where user='root';
flush privileges;
exit;
4. 在/etc/my.cnf 中去掉免密码登录的配置
#skip-grant-tables
5. 启动mysql服务
service mysql restart