Deploying MySQL 5.7 Using Official Yum Repositories on CentOS
Default repositories in CentOS 7 prioritize MariaDB over MySQL. Executing standard installation commands will result in MariaDB being deployed instead. To utilize the official MySQL packages via the package manager, the specific repository configuration must be added mnaually.
Configure the Official Repository
Retrieve and install the repository RPM package directly from the MySQL dev portal. This step registers the necessary sources without requiring manual file navigation.
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Install MySQL Server
With the repository enabled, install the community server package.
yum install -y mysql-community-server
Manage the Service
Initialize the daemon and configure it to launch during system boot.
systemctl start mysqld
systemctl enable mysqld
Verify the process is running:
ps aux | grep mysqld
Retrieve Temporary Credentials
Version 5.7 enforces security policies that generate a random root password during initialization. This credential is stored in the log file.
grep -i "temporary password" /var/log/mysqld.log
The output will display a string similar to root@localhost: generated_password. Extract the password portion following the colon.
Secure the Installation
Authenticate using the temporary password:
mysql -u root -p
Once inside the shell, enforce a new compliant password. The policy requires a mix of characters, numbers, and symbols with a minimum length.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewSecurePass123!';
Exit the client and reconnect using the new credentials to verify the configuration is complete.