You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS 7 无法安装MySQL 5.7,始终尝试安装MariaDB求助

Fixing MySQL 5.7 Installation Issue on CentOS 7 (Overcoming MariaDB & cPanel Conflicts)

Hey there, let's work through this frustrating installation problem. Those cPanel-related MySQL packages you're seeing (cpanel-mysql-5.1.73-1.cp1156.x86_64 and cpanel-perl-524-DBD-mysql-4.042-1.cp1168.x86_64) are almost certainly conflicting with your attempt to install official MySQL 5.7, and there might still be residual repo settings pushing MariaDB instead. Here's a step-by-step fix:

Step 1: Remove Conflicting cPanel MySQL Packages

First, we need to eliminate those old cPanel-managed MySQL packages since they're competing with the official MySQL repo. Important: Back up any existing databases first if you have data you want to keep! Then use the --nodeps flag to force uninstall:

rpm -e --nodeps cpanel-mysql-5.1.73-1.cp1156.x86_64 cpanel-perl-524-DBD-mysql-4.042-1.cp1168.x86_64

Step 2: Fully Disable MariaDB Repositories

Just using yum-config-manager might not be enough—let's make sure no MariaDB repos are active:

  • Rename any MariaDB repo files to disable them outright:
    mv /etc/yum.repos.d/MariaDB.repo /etc/yum.repos.d/MariaDB.repo.disabled
    
  • Double-check other system repos (like CentOS base repos) to ensure they don't include MariaDB in their package lists. If you find any MariaDB sections, edit the repo file and set enabled=0.

Step 3: Verify MySQL 5.7 Repo is Enabled

Confirm the MySQL 5.7 repo is the only active MySQL repo:

  • Enable MySQL 5.7 and disable newer versions (like 8.0) with these commands:
    yum-config-manager --enable mysql57-community
    yum-config-manager --disable mysql80-community
    
  • You can also manually edit /etc/yum.repos.d/mysql-community.repo to ensure this section is correctly set:
    [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
    
    Set enabled=0 for all other mysql*-community sections in the file.

Step 4: Clear Yum Cache & Refresh

Outdated cache might still be pointing to MariaDB. Clear it and rebuild the cache to get fresh package info:

yum clean all
rm -rf /var/cache/yum
yum makecache

Step 5: Install MySQL 5.7

Now try installing again, explicitly targeting the official MySQL 5.7 package:

yum install mysql-community-server

If you still see MariaDB being pulled in, add a flag to exclude all MariaDB repos:

yum install mysql-community-server --disablerepo=*mariadb*

Step 6: Verify Installation

Once installed, start and enable the MySQL service to make it run on boot:

systemctl start mysqld
systemctl enable mysqld

Check the installed version to confirm success:

mysql --version

Quick Heads-Up

If you were using the cPanel MySQL instance before, double-check that you backed up all databases with mysqldump before uninstalling the cPanel packages—this prevents data loss when switching to the official MySQL 5.7.

内容的提问来源于stack exchange,提问作者phlipinmi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 06:23:21