CentOS 7にMySQL 5.5をインストール（SCL）

# はじめに

Software Collection(SCL)を利用してCentOS7にMySQL5.5をインストール
親記事：[MySQL, MariaDBの各種インストール方法とEOLまとめ \- Qiita](https://qiita.com/witchcraze/items/72291ee035437ec83273)
参考：[Quick Start — Software Collections](https://www.softwarecollections.org/en/docs/)

## サポート

本手法で導入した場合、[Red Hat Software Collections Product Life Cycle - Red Hat Customer Portal](https://access.redhat.com/support/policy/updates/rhscl)より、2016-10がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### レポジトリ登録

```shell-session
# yum install -y centos-release-scl
```

### インストール

```shell-session
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

# yum install -y mysql55
# scl enable mysql55 bash
... 略
```

### mysql起動/停止

```shell-session
# systemctl start mysql55-mysqld
# systemctl status mysql55-mysqld
● mysql55-mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysql55-mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-21 14:18:44 UTC; 17s ago
  Process: 303 ExecStartPost=/usr/bin/scl enable $MYSQL55_SCLS_ENABLED -- /opt/rh/mysql55/root/usr/libexec/mysqld-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 222 ExecStartPre=/usr/bin/scl enable $MYSQL55_SCLS_ENABLED -- /opt/rh/mysql55/root/usr/libexec/mysqld-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 216 ExecStartPre=/usr/bin/scl enable $MYSQL55_SCLS_ENABLED -- /usr/bin/scl_enabled mysql55 (code=exited, status=0/SUCCESS)
 Main PID: 302 (scl)
   CGroup: /docker/6a76f167ea16b9cf0c4d2c3e6fc0758f58b60d71ed0611a8ab939779aa5d5880/system.slice/mysql55-mysqld.service
           tq302 /usr/bin/scl enable mysql55 -- /opt/rh/mysql55/root/usr/bin/mysqld_safe --basedir=/opt/rh/...
           tq304 /bin/bash /var/tmp/sclXTIRtH
           tq311 /bin/sh /opt/rh/mysql55/root/usr/bin/mysqld_safe --basedir=/opt/rh/mysql55/root/usr
           mq490 /opt/rh/mysql55/root/usr/libexec/mysqld --basedir=/opt/rh/mysql55/root/usr --datadir=/opt/...
           ? 302 /usr/bin/scl enable mysql55 -- /opt/rh/mysql55/root/usr/bin/mysqld_safe --basedir=/opt/rh/...

Oct 21 14:18:38 6a76f167ea16 scl[222]: strongly recommended for production servers.
Oct 21 14:18:38 6a76f167ea16 scl[222]: See the manual for more instructions.
Oct 21 14:18:38 6a76f167ea16 scl[222]: You can start the MySQL daemon with:
Oct 21 14:18:38 6a76f167ea16 scl[222]: systemctl start mysql55-mysqld
Oct 21 14:18:38 6a76f167ea16 scl[222]: You can test the MySQL daemon with mysql-test-run.pl
Oct 21 14:18:38 6a76f167ea16 scl[222]: after installing mysql55-mysql-test package.
Oct 21 14:18:38 6a76f167ea16 scl[222]: See /opt/rh/mysql55/root/usr/share/mysql-test/README for instructions.
Oct 21 14:18:39 6a76f167ea16 scl[302]: 191021 14:18:39 mysqld_safe Logging to '/var/log/mysql55-mysqld.log'.
Oct 21 14:18:39 6a76f167ea16 scl[302]: 191021 14:18:39 mysqld_safe Starting mysqld daemon with databas...mysql
Oct 21 14:18:44 6a76f167ea16 systemd[1]: Started MySQL database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

```shell-session
# systemctl stop mysql55-mysqld
# systemctl status mysql55-mysqld
● mysql55-mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysql55-mysqld.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 21 14:18:38 6a76f167ea16 scl[222]: You can start the MySQL daemon with:
Oct 21 14:18:38 6a76f167ea16 scl[222]: systemctl start mysql55-mysqld
Oct 21 14:18:38 6a76f167ea16 scl[222]: You can test the MySQL daemon with mysql-test-run.pl
Oct 21 14:18:38 6a76f167ea16 scl[222]: after installing mysql55-mysql-test package.
Oct 21 14:18:38 6a76f167ea16 scl[222]: See /opt/rh/mysql55/root/usr/share/mysql-test/README for instructions.
Oct 21 14:18:39 6a76f167ea16 scl[302]: 191021 14:18:39 mysqld_safe Logging to '/var/log/mysql55-mysqld.log'.
Oct 21 14:18:39 6a76f167ea16 scl[302]: 191021 14:18:39 mysqld_safe Starting mysqld daemon with databas...mysql
Oct 21 14:18:44 6a76f167ea16 systemd[1]: Started MySQL database server.
Oct 21 14:19:32 6a76f167ea16 systemd[1]: Stopping MySQL database server...
Oct 21 14:19:33 6a76f167ea16 systemd[1]: Stopped MySQL database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

### mysql自動起動設定/設定解除

```shell-session
# systemctl enable mysql55-mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysql55-mysqld.service to /usr/lib/systemd/system/mysql55-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
mysql55-mysqld.service                 enabled
```

```shell-session
# systemctl disable mysql55-mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/mysql55-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
mysql55-mysqld.service                 disabled
```

### 各種確認

```shell-session
# systemctl start mysql55-mysqld
# mysql -u root -e'select version();'
+-----------+
| version() |
+-----------+
| 5.5.52    |
+-----------+
```