How to enable repo with yum-config-manager –enable

yum

During the try to install yum-utils, I ran into the problem that there seems to be no enabled repos. How can I enable yum-config-manager, when I seem to need him to do so.

[root@spectrumscale ~]# yum install yum-utils
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
You can enable repos with yum-config-manager --enable <repo>

Best Answer

To install specific package from specific repo you can use

yum install --enablerepo=name-of-repo name-of-package

Say there can be conflict between version, consider example of installing mariadb 5.5.66, in my case I got 2 repo mariadb-5 and mariadb-10, suppose if I wish to install from mariadb-5 repo then I use

yum install --disablerepo=mariadb-10  --enablerepo=mariadb-5  MariaDB-server MariaDB-client

To enable enable specific repo, you can use

yum-config-manager --enable name-of-repo

Here is example on Centos 7.7

[root@localhost server-setup]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

[root@localhost server-setup]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: mirror.poliwangi.ac.id
 * extras: mirrors.piconets.webwerks.in
 * remi-safe: mirror.innosol.asia
 * updates: mirrors.piconets.webwerks.in
repo id                                               repo name                                                                                        status
CodeIT/x86_64                                         CodeIT repo                                                                                         369
base/7/x86_64                                         CentOS-7 - Base                                                                                  10,097
epel/x86_64                                           Extra Packages for Enterprise Linux 7 - x86_64                                                   13,453
extras/7/x86_64                                       CentOS-7 - Extras                                                                                   305
ius/x86_64                                            IUS for Enterprise Linux 7 - x86_64                                                                 641
mariadb-10                                            MariaDB                                                                                              94
mariadb-5                                             MariaDB                                                                                              39
remi-safe                                             Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                                        3,621
updates/7/x86_64                                      CentOS-7 - Updates                                                                                  711
repolist: 29,330

To Disable

[root@localhost server-setup]# yum-config-manager --disable mariadb-5

After Disabling

[root@localhost server-setup]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: mirror.poliwangi.ac.id
 * extras: mirrors.piconets.webwerks.in
 * remi-safe: mirror.innosol.asia
 * updates: mirrors.piconets.webwerks.in
repo id                                               repo name                                                                                        status
CodeIT/x86_64                                         CodeIT repo                                                                                         369
base/7/x86_64                                         CentOS-7 - Base                                                                                  10,097
epel/x86_64                                           Extra Packages for Enterprise Linux 7 - x86_64                                                   13,453
extras/7/x86_64                                       CentOS-7 - Extras                                                                                   305
ius/x86_64                                            IUS for Enterprise Linux 7 - x86_64                                                                 641
mariadb-10                                            MariaDB                                                                                              94
remi-safe                                             Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                                        3,621
updates/7/x86_64                                      CentOS-7 - Updates                                                                                  711
repolist: 29,291

What it actually does ???

I got MariaDB.repo file at /etc/yum.repos.d/, when you use --enable <repo-name> or --disable <repo-name>, it will change the value of enabled = to 0 or 1, based on this, yum repolist will show you repositories.

[root@localhost server-setup]# cat /etc/yum.repos.d/MariaDB.repo 
[mariadb-10]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4.10/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[mariadb-5]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5.66/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled = 1
Related Topic