2017-04-19
一.实验环境
centos7_x64
由于centos7的yum源里默认使用了mariadb替代了mysql,所有我们还得先配置一下yum源。当然mariadb和mysql是兼容的,所有命令都通用。
二.yum安装mysql
1.配置yum源
这里我选用了aliyun的源,速度还可以。如果是安装mariadb可以直接使用yum install mariadb mariadb-server安装客户端和服务器端。
备份
1 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载新的CentOS-Base.repo 到/etc/yum.repos.d/
1 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
为了安装mysql,我们还要下载一个mysql的repo,步骤如下:
到这个网址:http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/ 找到mysql57-community-release-el7-10.noarch.rpm并下载下来。
[root@sharestore download]# wget http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
[root@sharestore download]# rpm -ivh mysql57-community-release-el7-10.noarch.rpm
2. 安装mysql
[root@sharestore download]# yum install mysql-community-server
yum自动检查依赖关系,以下4个包被一同装上:
1 (1/4): mysql-community-common-5.7.18-1.el7.x86_64.rpm | 271 kB 00:01
2 (2/4): mysql-community-libs-5.7.18-1.el7.x86_64.rpm | 2.1 MB 00:05
3 (3/4): mysql-community-client-5.7.18-1.el7.x86_64.rpm | 24 MB 08:51
4 (4/4): mysql-community-server-5.7.18-1.el7.x86_64.rpm | 162 MB 52:30