检查mysql服务是否启动,如果启动就关闭
#检查ps -ef | grep -i mysql#关闭service mysqld stop
修改mysql的配置文件my.conf
1.进入文件
vi /etc/my.cnf
2.在文件的[mysqld]标签下添加一句:skip-grant-tables,最后保存退出

启动数据库
service mysqld start
修改密码
1.进入mysql
mysql -u root
2.切换到mysql表
use mysql;
3.修改
update user set authentication_string=password("112233") where user='root';
4.exit退出,重新登录
重新进入mysql的配置文件my.conf
将刚才添加的skip-grant-tables删除
vi /etc/my.cnf
重启数据库
service mysqld restart
用刚才修改的密码重新登录mysql就好了
musql -u root -p
