1. 查看系统是否已经安装mysql和mariadb数据库
[root@dazhang ~]# rpm -qa | grep mysql
[root@dazhang ~]# rpm -qa | grep mariadb
2.下载mysql8.0 源
[root@dazhang yum.repos.d]# wget http://repo.mysql.com/mysql80-community-release-el7.rpm
3. 安装rpm 源
[root@dazhang yum.repos.d]# rpm -ivh mysql80-community-release-el7.rpm
4. 安装mysql
[root@dazhang yum.repos.d]# yum install -y @mysql
5.启动mysql 服务,加入开机自启动
[root@dazhang yum.repos.d]# systemctl start mysqld.service
[root@dazhang yum.repos.d]# systemctl enable mysqld.service
6.查看sql 版本
[root@dazhang yum.repos.d]# mysql –V
7.按照提示初始化数据库,设置密码
[root@dazhang yum.repos.d]# mysql_secure_installation