1:跳过密码登陆 //找到mysql配置文件:my.cnf: vi /etc/my.cnf
在【mysqld】模块添加:skip-grant-tables 保存退出;
2://使配置生效
重启mysql服务: service mysqld restart;
3:登陆数据库: mysql -u root -p //提示输入密码时直接敲回车。
4:use mysql; //选择数据库
5:更改密码 //update user set authentication_string = '新密码' where user = 'root';
6:quit //退出
7:删掉步骤1的语句 skip-grant-tables
重启服务 service mysqld restart