vi /etc/my.cnf
[mysqld]#下添加
skip-grant-tables=1
重启mysql服务
/etc/init.d/mysqld restart
mysql update mysql.user set password=password("123456") where user="root"; flush privileges;
vi /etc/my.cnf
删除
skip-grant-tables=1
重启mysql服务
/etc/init.d/mysqld restart