linux自带yum源中mysql是什么版本?
答案是:mariadb
我们可以从yum中的命令告诉我们,例如下
[root@dr yum.repos.d]# yum provides mysql
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
1:mariadb-5.5.68-1.el7.x86_64 : A community developed branch of MySQL
源 :base
匹配来源:
提供 :mysql = 1:5.5.68-1.el7
provides是查询命令是包含在哪个软件包中
从上面的执行结果可以得出,yum 的base源中是mariadb数据库
配置mysql的yum 源
直接使用yum源下载安装mysql的yum源软件包
yum -y install https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
[root@dr yum.repos.d]# yum -y install https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
已加载插件:fastestmirror
mysql57-community-release-el7-11.noarch.rpm | 25 kB 00:00:00
正在检查 /var/tmp/yum-root-HCOw6z/mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch
/var/tmp/yum-root-HCOw6z/mysql57-community-release-el7-11.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql57-community-release.noarch.0.el7-11 将被 安装
--> 解决依赖关系完成
依赖关系解决
===================================================================================
Package 架构 版本 源 大小
===================================================================================
正在安装:
mysql57-community-release
noarch el7-11 /mysql57-community-release-el7-11.noarch 31 k
事务概要
===================================================================================
安装 1 软件包
总计:31 k
安装大小:31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mysql57-community-release-el7-11.noarch 1/1
验证中 : mysql57-community-release-el7-11.noarch 1/1
已安装:
mysql57-community-release.noarch 0:el7-11
完毕!
查看yum源配置文件
[root@dr yum.repos.d]# ls
CentOS-Base.repo CentOS-Media.repo epel-testing.repo
CentOS-CR.repo CentOS-Sources.repo mysql-community.repo
CentOS-Debuginfo.repo CentOS-Vault.repo mysql-community-source.repo
CentOS-fasttrack.repo epel.repo
查看mysql yum源文件中包含的信息
[root@dr yum.repos.d]# cat mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# 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/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-preview]
name=MySQL Tools Preview
baseurl=http://repo.mysql.com/yum/mysql-tools-preview/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-cluster-7.5-community]
name=MySQL Cluster 7.5 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-7.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-cluster-7.6-community]
name=MySQL Cluster 7.6 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-7.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@dr yum.repos.d]#
现在就可以直接用yum -y install mysql 直接安装mysql服务了
那么为什么会给我们下载5.7而不下载其他的版本呢?
这个从上面查看的文件内容中可以看到只有mysql5.7的enable是等于1 的 (0代表关闭,1代表开启)
也可以用yum repolist all | grep mysql命令给我们的反馈中更直接的看到结果
[root@dr yum.repos.d]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community 禁用
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community 禁用
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用
mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 192
mysql-connectors-community-source MySQL Connectors Community - Sou 禁用
mysql-tools-community/x86_64 MySQL Tools Community 启用: 90
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql-tools-preview/x86_64 MySQL Tools Preview 禁用
mysql-tools-preview-source MySQL Tools Preview - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sou 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 禁用
mysql56-community-source MySQL 5.6 Community Server - Sou 禁用
mysql57-community/x86_64 MySQL 5.7 Community Server 启用: 584
mysql57-community-source MySQL 5.7 Community Server - Sou 禁用
mysql80-community/x86_64 MySQL 8.0 Community Server 禁用
mysql80-community-source MySQL 8.0 Community Server - Sou 禁用
这要注意: 版本的开启要保持是一个
除了手动修改mysql源的enable的值来控制mysql安装的版本,还有其他方法吗?
当然
我们可以使用
yum -config-manager 命令来更改enable的值
如果找不到此命令可以用上面的provides查看此命令的安装包然后进行安装
[root@RS-1 ~]# yum provides yum-config-manager
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
base/7/x86_64/filelists_db | 7.2 MB 00:00:20
epel/x86_64/filelists_db | 12 MB 00:00:02
extras/7/x86_64/filelists_db | 277 kB 00:00:00
updates/7/x86_64/filelists_db | 9.1 MB 00:00:01
yum-utils-1.1.31-54.el7_8.noarch : Utilities based around the yum package manager
源 :base
匹配来源:
文件名 :/usr/bin/yum-config-manager
下载安装软件包
[root@RS-1 ~]# yum -y install yum-utils-1.1.31-54.el7_8.noarch
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 安装
--> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要
--> 正在检查事务
---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_9.6 将被 安装
--> 正在处理依赖关系 libxml2 = 2.9.1-6.el7_9.6,它被软件包 libxml2-python-2.9.1-6.el7_9.6.x86_64 需要
---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装
--> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要
--> 正在检查事务
---> 软件包 libxml2.x86_64.0.2.9.1-6.el7_2.3 将被 升级
---> 软件包 libxml2.x86_64.0.2.9.1-6.el7_9.6 将被 更新
---> 软件包 python-chardet.noarch.0.2.2.1-3.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================================================================
Package 架构 版本 源 大小
================================================================================================================================
正在安装:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
为依赖而安装:
libxml2-python x86_64 2.9.1-6.el7_9.6 updates 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
为依赖而更新:
libxml2 x86_64 2.9.1-6.el7_9.6 updates 668 k
事务概要
================================================================================================================================
安装 1 软件包 (+3 依赖软件包)
升级 ( 1 依赖软件包)
总下载量:1.5 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/5): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
(2/5): libxml2-2.9.1-6.el7_9.6.x86_64.rpm | 668 kB 00:00:00
(3/5): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm | 247 kB 00:00:01
(4/5): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:01
(5/5): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:06
--------------------------------------------------------------------------------------------------------------------------------
总计 237 kB/s | 1.5 MB 00:00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : libxml2-2.9.1-6.el7_9.6.x86_64 1/6
正在安装 : libxml2-python-2.9.1-6.el7_9.6.x86_64 2/6
正在安装 : python-chardet-2.2.1-3.el7.noarch 3/6
正在安装 : python-kitchen-1.1.1-5.el7.noarch 4/6
正在安装 : yum-utils-1.1.31-54.el7_8.noarch 5/6
清理 : libxml2-2.9.1-6.el7_2.3.x86_64 6/6
验证中 : python-chardet-2.2.1-3.el7.noarch 1/6
验证中 : libxml2-2.9.1-6.el7_9.6.x86_64 2/6
验证中 : libxml2-python-2.9.1-6.el7_9.6.x86_64 3/6
验证中 : python-kitchen-1.1.1-5.el7.noarch 4/6
验证中 : yum-utils-1.1.31-54.el7_8.noarch 5/6
验证中 : libxml2-2.9.1-6.el7_2.3.x86_64 6/6
已安装:
yum-utils.noarch 0:1.1.31-54.el7_8
作为依赖被安装:
libxml2-python.x86_64 0:2.9.1-6.el7_9.6 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
作为依赖被升级:
libxml2.x86_64 0:2.9.1-6.el7_9.6
完毕!
那么怎么来用呢
–help
[root@RS-1 ~]# yum-config-manager --help
已加载插件:fastestmirror
Usage: yum-config-manager [options] [section ...]
Options:
插件选项:
Yum Base Options:
-h, --help 显示此帮助消息并退出
-t, --tolerant 忽略错误
-C, --cacheonly 完全从系统缓存运行,不升级缓存
-c [config file], --config=[config file]
配置文件路径
-R [minutes], --randomwait=[minutes]
命令最长等待时间
-d [debug level], --debuglevel=[debug level]
调试输出级别
--showduplicates 在 list/search 命令下,显示源里重复的条目
-e [error level], --errorlevel=[error level]
错误输出级别
--rpmverbosity=[debug level name]
RPM 调试输出级别
-q, --quiet 静默执行
-v, --verbose 详尽的操作过程
-y, --assumeyes 回答全部问题为是
--assumeno 回答全部问题为否
--version 显示 Yum 版本然后退出
--installroot=[path]
设置安装根目录
--enablerepo=[repo]
启用一个或多个软件源(支持通配符)
--disablerepo=[repo]
禁用一个或多个软件源(支持通配符)
-x [package], --exclude=[package]
采用全名或通配符排除软件包
--disableexcludes=[repo]
禁止从主配置,从源或者从任何位置排除
--disableincludes=[repo]
disable includepkgs for a repo or for everything
--obsoletes 更新时处理软件包取代关系
--noplugins 禁用 Yum 插件
--nogpgcheck 禁用 GPG 签名检查
--disableplugin=[plugin]
禁用指定名称的插件
--enableplugin=[plugin]
启用指定名称的插件
--skip-broken 忽略存在依赖关系问题的软件包
--color=COLOR 配置是否使用颜色
--releasever=RELEASEVER
在 yum 配置和 repo 文件里设置 $releasever 的值
--downloadonly 仅下载而不更新
--downloaddir=DLDIR
指定一个其他文件夹用于保存软件包
--setopt=SETOPTS 设置任意配置和源选项
--bugfix Include bugfix relevant packages, in updates
--security Include security relevant packages, in updates
--advisory=ADVS, --advisories=ADVS
Include packages needed to fix the given advisory, in
updates
--bzs=BZS Include packages needed to fix the given BZ, in
updates
--cves=CVES Include packages needed to fix the given CVE, in
updates
--sec-severity=SEVS, --secseverity=SEVS
Include security relevant packages matching the
severity, in updates
yum-config-manager options:
--save save the current options (useful with --setopt)
--enable enable the specified repos (automatically saves)
--disable disable the specified repos (automatically saves)
--add-repo=ADDREPO add (and enable) the repo from the specified file or
url
这时我们便可以知道使用disable和enable来控制了
例如
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql80-community
你再去观察mysql的yum源文件时你就会发现相应版本的enable的值已经改变
其中mysql57-community和mysql80-community就是我们平常配置yum配置文件时的[ ]的内容
写了一篇废话,其实就是想让你明白知识不是死记硬背的都是有理可寻的。