centos7安装MYSQL

1.查看版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
2.将mysql yum添加到系统的仓库列表中
3.验证安装
[root@localhost ~]# yum repolist enabled | grep ‘mysql.*-community.*’
mysql-connectors-community/x86_64       MySQL Connectors Community           108
mysql-tools-community/x86_64            MySQL Tools Community                 90
mysql57-community/x86_64                MySQL 5.7 Community Server           347
4.确认要安装的MYSQL版本
[root@localhost ~]# yum repolist all | grep mysql5
mysql55-community/x86_64          MySQL 5.5 Community Server        禁用
mysql55-community-source          MySQL 5.5 Community Server – Sour 禁用
mysql56-community/x86_64          MySQL 5.6 Community Server        禁用
mysql56-community-source          MySQL 5.6 Community Server – Sour 禁用
mysql57-community/x86_64          MySQL 5.7 Community Server        启用:    347
mysql57-community-source          MySQL 5.7 Community Server – Sour 禁用
5.安装
yum install mysql-community-server
6.查看root的初始密码
[root@localhost ~]# cat /var/log/mysqld.log | grep generated
2019-05-28T12:20:44.090447Z 1 [Note] A temporary password is generated for root@localhost: vtK#Bt?Hl35u
7.修改root密码
set password for root@localhost=password(‘vtK#Bt?Hl35u’);