1、使用命令 " vi /etc/my.cnf " 进入配置文件。
2、将 " skip-grant-tables " 放开,esc --> : --> wq 保存并退出。
3、输入 " service mysqld restart " 重启mysql服务。
4、登录mysql服务 "mysql -u root -p "。
5、使用命令 "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码' "修改密码。
6、使用命令 "flush privileges" 更新。
7、按照步骤一和步骤二将 " skip-grant-tables " 注释掉 保存即完成修改密码。