拥有原来的用户名账户的密码
忘记原来root密码
service mysqld stopvim /etc/my.cnf如图,将:
service mysqld startmysql -u root -p第五步:设置root用户密码
注意:代码中root_password就是新设置的密码
use mysql;update mysql.user set authentication_string=password('root_password') where user='root'; 第六步:退出MySQL,关闭MySQL服务,将my.cnf中的skip-grant-tables注释
关闭MySQL服务
service mysqld stop注释skip-grant-tables,如图
启动MySQL服务
service mysqld start