systemctl list-unit-files|grep mysqld #检查是否已经设置为开机启动MySQL服务 image.png

systemctl enable mysqld.service #设置开机启动 image.png

systemctl list-unit-files|grep mysqld image.png

ps -ef|grep mysql # 查看是否启动MySQL服务

systemctl start mysqld.service #启动服务

image.png

这时已经进入到maisql中了 mysql> use mysql; #先把密码置为空字符串;(不让后面修改密码会报错) mysql> update user set authentication_string="" where user="root"; #这个刷新非常有必要;不让后面执行alter就会出错 mysql> flush privileges; mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';

image.png