直接上命令,先停止mysql服务
systemctl stop mysql
跳过密码检测:
mysqld –console –skip-grant-tables –shared-memory
启动mysql服务
systemctl start mysql
登录MySQL
mysql -uroot -p
直接回车,即可进入MySQL命令提示行,使用下面命令设置root密码:
use mysql;
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘密码’;
FLUSH PRIVILEGES;
exit;