Yum安装MySQL

①配置MySQL yum源

在MySQL官网( https://dev.mysql.com/downloads/repo/yum/)中寻找合适的rpm包,自动配置yum源

# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

根据需求修改配置文件/etc/yum.repos.d/mysql-community.repo

假设我们安装的是 MySQL-5.6.43,则启动如下yum源

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

建立缓存:# yum makecache

如果需要清空之前yum缓存则: # yum clean all

检测yum仓库是否启用: # yum repolist

②安装 MySQL

# yum install mysql-community-server

注意:默认安装yum源中最新版本,若需要指定版本安装,则在包名后指定版本号,如下

# yum install mysql-community-server-5.6.43

若相关依赖也需要指定版本安装,则指定每个依赖包的版本号,如下:

# yum install mysql-community-server-5.6.43 mysql-community-common-5.6.43 mysql-community-libs-5.6.43 mysql-community-client-5.6.43 mysql-community-libs-compat-5.6.43

③验证

# service mysqld start
# service mysqld status
mysqld (pid  3106) is running...

若显示以上信息则表示启动成功

Last modification:April 4th, 2019 at 10:50 pm