第一步:查询yum中mysql的版本
yum list mysql-server
第二步:使用yum安装mysql
yum install mysql-server
第三步:查询mysql的状态
systemctl status mysqld
目前是显示 dead 未启动。
第四步:启动mysql服务
systemctl start mysqld
第五步:登录mysql
mysql -uroot -p #不需要输入密码,直接回车,默认密码为空
![](https://img-blog.csdnimg.cn/c00f85440f644ffea89190ec2ff40ff7.png)
第六步:设置mysql登录密码
alter user root@localhost identified by 'password';
结果ok 就表示成功了
重置mysql登录密码
(1)选择管理user表的数据库
use mysql;
(2) 将authentication_string 置空
update user set authentication_string='' where user='root';
(3)将plugin改为以前版本的密码认证方式
update user set plugin='mysql_native_password' where user='root';
(4)刷新权限
FLUSH PRIVILEGES;
(5)修改密码
alter user 'root'@'localhost' identified by 'newpassword';