Preferred version: MySQL 5.7.
| Parameter | Value |
|---|---|
| Default port | 3306 |
Installation (CentOS)
CentOS 7 dropped MySQL from default repos in favor of MariaDB (largely compatible). To install Oracle MySQL, add the official Yum repo from open_in_new dev.mysql.com/downloads/repo/yum/ .
The repo package installs MySQL 8.0 by default. Edit the repo file to enable 5.7 instead if needed.
The repo package installs:
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
Download and install the repo (example for el7):
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
Enable the 5.7 repo and disable 8.0 in /etc/yum.repos.d/mysql-community.repo, then:
yum install mysql-community-server
Or for MySQL 8.0 as shipped by the repo:
yum install mysql-server
Start and secure
On CentOS the service is usually enabled at boot. Start it:
systemctl start mysqld
Temporary root password from the log:
grep 'temporary password' /var/log/mysqld.log
Run the secure setup script:
mysql_secure_installation
Troubleshooting
Leftover data after downgrade (8.0 → 5.7)
If MySQL 5.7 fails to start after removing 8.0, old data files may remain. Removing /var/lib/mysql/ (after backup) can fix a clean reinstall.
caching_sha2_password plugin (MySQL 8)
Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
MySQL 8 uses a new default authentication plugin. Switch the user to the legacy plugin:
ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
MySQL Workbench and MySQL 8
When creating users, Workbench may fail with SQL syntax errors around MAX_QUERIES_PER_HOUR — it targets MySQL 5.x better. Prefer MySQL 5.7 for compatibility with older tooling.
Andrew Dorokhov