1. 下载MySql YUM源:

  参考官方文档:https://dev.mysql.com/downloads/repo/yum/ 

    

 # 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源

shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

(安装后,更改了centos的yum库mysql版本信息。可以直接用yum install 安装mysql。 

如果直接下载mysql-community-serve rpm安装,则会找不到其他依赖,安装起来比较麻烦。)

检查mysql源是否安装成功

shell> yum repolist enabled | grep "mysql.*-community.*"


看到上图所示表示安装成功!

可以通过修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1:


2. 安装MySql

shell> yum install mysql-community-server

3、启动MySQL服务

shell> systemctl start mysqld

4、开机启动
shell> systemctl enable mysqld

shell> systemctl daemon-reload



Logo

更多推荐