1.下载mysql的yum仓库包
sudo wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
2.安装mysql的yum仓库
sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
3.用yum安装mysql,可以修改配置文件/etc/yum.repos.d/mysql-community.repo来选择要安装的版本(enable字段)
sudo yum install mysql-community-server
4.启动mysql,centos7以后都是用systemctl来管理
sudo systemctl start msyqld
5.查看mysql的初始化密码
sudo grep 'temporary password' /var/log/mysqld.log
找到生成的临时密码
6.进入数据库
mysql -uroot -p #输入上面查看到的密码
7.修改密码,否则啥都干不了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
命名需要复杂一点,大小写,特殊符号,数字都要有