はじめに
Software Collection(SCL)を利用してCentOS7にMySQL8.0をインストール
親記事:MySQL, MariaDBの各種インストール方法とEOLまとめ - Qiita
参考:Quick Start — Software Collections
サポート
本手法で導入した場合、Red Hat Software Collections Product Life Cycle - Red Hat Customer Portalより、2023-04がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。
LOG
レポジトリ登録
# yum install -y centos-release-scl
インストール
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
# yum install -y rh-mysql80
# scl enable rh-mysql80 bash
... 略
mysql起動/停止
# systemctl start rh-mysql80-mysqld
# systemctl status rh-mysql80-mysqld
● rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-10-21 14:48:30 UTC; 1s ago
Process: 412 ExecStartPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 280 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 252 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 246 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql80 (code=exited, status=0/SUCCESS)
Main PID: 367 (mysqld)
Status: "Server is operational"
CGroup: /docker/4c8c60bc999ed28314e7cae02bd0fc503fa4b803b08a98137ccb180e43246168/system.slice/rh-mysql80-mysqld.service
mq367 /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr
? 367 /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr
Oct 21 14:48:04 4c8c60bc999e systemd[1]: Starting MySQL 8.0 database server...
Oct 21 14:48:05 4c8c60bc999e scl[280]: Initializing MySQL database
Oct 21 14:48:30 4c8c60bc999e systemd[1]: Started MySQL 8.0 database server.
# systemctl stop rh-mysql80-mysqld
# systemctl status rh-mysql80-mysqld
● rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Oct 21 14:48:04 4c8c60bc999e systemd[1]: Starting MySQL 8.0 database server...
Oct 21 14:48:05 4c8c60bc999e scl[280]: Initializing MySQL database
Oct 21 14:48:30 4c8c60bc999e systemd[1]: Started MySQL 8.0 database server.
Oct 21 14:48:47 4c8c60bc999e systemd[1]: Stopping MySQL 8.0 database server...
Oct 21 14:48:48 4c8c60bc999e systemd[1]: Stopped MySQL 8.0 database server.
mysql自動起動設定/設定解除
# systemctl enable rh-mysql80-mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mysql80-mysqld.service to /usr/lib/systemd/system/rh-mysql80-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql80-mysqld.service enabled
rh-mysql80-mysqld@.service disabled
# systemctl disable rh-mysql80-mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-mysql80-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql80-mysqld.service disabled
rh-mysql80-mysqld@.service disabled
各種確認
# systemctl start rh-mysql80-mysqld
# mysql -u root -e 'select version();'
+-----------+
| version() |
+-----------+
| 8.0.17 |
+-----------+