Many CentOS users face a frustrating situation where their attempts to install MySQL get automatically redirected to MariaDB installations. This occurs because:
- MariaDB is configured as the default MySQL replacement in CentOS repositories
- Package obsoletes tags force yum to prefer MariaDB
- Shared library dependencies create complex conflicts
First, we need to thoroughly clean up existing installations:
# Stop running services
sudo systemctl stop mariadb
sudo systemctl stop mysql
# Remove all packages
sudo yum remove mariadb-server mariadb-client mariadb-libs mariadb-common
sudo yum remove mysql-server mysql-libs mysql-devel mysql-community-server
# Clean up residual files
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/my.cnf
sudo rm -rf /etc/my.cnf.d
Since CentOS repositories favor MariaDB, we need to add MySQL's official repo:
# Download and install the MySQL Yum repository
sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
# Verify the repository is properly configured
sudo yum repolist enabled | grep "mysql.*-community.*"
The key to successful MySQL installation lies in managing dependencies:
# First install required libraries
sudo yum install openssl openssl-devel
# Disable MariaDB repository temporarily
sudo yum-config-manager --disable mariadb
# Install MySQL with explicit version specification
sudo yum --enablerepo=mysql80-community install mysql-community-server
After successful installation, verify everything works:
# Start MySQL service
sudo systemctl start mysqld
# Check status
sudo systemctl status mysqld
# Get temporary password
sudo grep 'temporary password' /var/log/mysqld.log
To prevent future conflicts:
# Create explicit version lock
sudo yum versionlock add mysql-community-server
# Set up proper alternatives
sudo alternatives --config mysql
If you encounter shared library errors:
# Check for conflicting libraries
ldd $(which mysqld) | grep not
# Create symbolic links if needed (example)
sudo ln -s /usr/lib64/libssl.so.1.1 /usr/lib64/libssl.so.10
sudo ln -s /usr/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.10
After upgrading my CentOS system, I faced an unexpected situation where attempts to install MySQL packages were automatically being redirected to MariaDB installations. This appears to be a known issue where CentOS/RHEL distributions prioritize MariaDB as a drop-in replacement for MySQL.
First, we need to completely purge all MariaDB components:
# List all installed MariaDB packages
rpm -qa | grep -i mariadb
# Remove all MariaDB components
sudo yum remove mariadb-server mariadb-client mariadb-common mariadb-devel
sudo yum remove MariaDB-server MariaDB-client MariaDB-common MariaDB-devel
# Clean up residual files
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/my.cnf*
The main challenge comes from the package obsoletes setting in CentOS repositories. We need to temporarily disable this behavior:
# Create a yum configuration file to exclude mariadb
sudo tee /etc/yum.repos.d/mysql-exclude-mariadb.repo <<EOF
[base]
exclude=mariadb* MariaDB*
[updates]
exclude=mariadb* MariaDB*
[extras]
exclude=mariadb* MariaDB*
EOF
Now we can install the official MySQL repositories and packages:
# Add MySQL community repository
sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# Disable MariaDB repository if present
sudo yum-config-manager --disable mariadb
# Install MySQL components
sudo yum install mysql-community-server mysql-community-client mysql-community-devel
If you encounter SSL dependency problems, consider these alternatives:
# For older systems needing compatibility libraries
sudo yum install compat-openssl10
# Or for a clean solution
sudo yum install openssl-devel
After successful installation, verify the MySQL installation:
# Start MySQL service
sudo systemctl start mysqld
# Check MySQL version
mysql --version
# Secure the installation
sudo mysql_secure_installation
For a more straightforward method, consider using MySQL's official Yum repository:
# Add MySQL Yum repository
sudo rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-5.noarch.rpm
# Verify repository configuration
yum repolist enabled | grep mysql
# Install MySQL server
sudo yum --enablerepo=mysql80-community install mysql-community-server