1. 查看系统是否已经安装mysql和mariadb数据库

[root@dazhang ~]# rpm -qa | grep mysql

[root@dazhang ~]# rpm -qa | grep mariadb

MySql 8.0安装_mysql8.0安装

2.下载mysql8.0 源

[root@dazhang yum.repos.d]# wget http://repo.mysql.com/mysql80-community-release-el7.rpm

MySql 8.0安装_db数据库_02

3. 安装rpm 源

[root@dazhang yum.repos.d]# rpm -ivh mysql80-community-release-el7.rpm

MySql 8.0安装_db数据库_03

4. 安装mysql

[root@dazhang yum.repos.d]# yum install -y @mysql

MySql 8.0安装_mysql8.0安装_04

MySql 8.0安装_mysql8.0安装_05

5.启动mysql 服务,加入开机自启动

[root@dazhang yum.repos.d]# systemctl start mysqld.service

[root@dazhang yum.repos.d]# systemctl enable mysqld.service

MySql 8.0安装_mysql_06

6.查看sql 版本

[root@dazhang yum.repos.d]# mysql –V

MySql 8.0安装_db数据库_07

7.按照提示初始化数据库,设置密码

[root@dazhang yum.repos.d]# mysql_secure_installation

MySql 8.0安装_mysql8.0安装_08

MySql 8.0安装_初始化_09