1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS 7にMySQL 5.7をインストール(SCL)

Posted at

はじめに

Software Collection(SCL)を利用してCentOS7にMySQL5.7をインストール
親記事:MySQL, MariaDBの各種インストール方法とEOLまとめ - Qiita
参考:Quick Start — Software Collections

サポート

本手法で導入した場合、Red Hat Software Collections Product Life Cycle - Red Hat Customer Portalより、2019-11がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

LOG

レポジトリ登録

# yum install -y centos-release-scl

インストール

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

# yum install -y rh-mysql57
# scl enable rh-mysql57 bash
... 略

mysql起動/停止

# systemctl start rh-mysql57-mysqld
# systemctl status rh-mysql57-mysqld
● rh-mysql57-mysqld.service - MySQL 5.7 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mysql57-mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-21 14:41:23 UTC; 2s ago
  Process: 374 ExecStartPost=/usr/bin/scl enable $RH_MYSQL57_SCLS_ENABLED -- /opt/rh/rh-mysql57/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 341 ExecStart=/opt/rh/rh-mysql57/root/usr/libexec/mysqld-scl-helper enable $RH_MYSQL57_SCLS_ENABLED -- /opt/rh/rh-mysql57/root/usr/libexec/mysqld --daemonize --basedir=/opt/rh/rh-mysql57/root/usr --pid-file=/var/run/rh-mysql57-mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 272 ExecStartPre=/usr/bin/scl enable $RH_MYSQL57_SCLS_ENABLED -- /opt/rh/rh-mysql57/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 244 ExecStartPre=/usr/bin/scl enable $RH_MYSQL57_SCLS_ENABLED -- /opt/rh/rh-mysql57/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
  Process: 238 ExecStartPre=/usr/bin/scl enable $RH_MYSQL57_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql57 (code=exited, status=0/SUCCESS)
 Main PID: 346 (mysqld)
   CGroup: /docker/9b923d2bfd11f4560910084714df4eaaf5cb9d71beed1f4e226ed570f9127ecd/system.slice/rh-mysql57-mysqld.service
           mq346 /opt/rh/rh-mysql57/root/usr/libexec/mysqld --daemonize --basedir=/opt/rh/rh-mysql57/root/u...
           ? 346 /opt/rh/rh-mysql57/root/usr/libexec/mysqld --daemonize --basedir=/opt/rh/rh-mysql57/root/u...

Oct 21 14:41:13 9b923d2bfd11 systemd[1]: Starting MySQL 5.7 database server...
Oct 21 14:41:13 9b923d2bfd11 scl[272]: Initializing MySQL database
Oct 21 14:41:23 9b923d2bfd11 systemd[1]: Started MySQL 5.7 database server.
# systemctl stop rh-mysql57-mysqld
# systemctl status rh-mysql57-mysqld
● rh-mysql57-mysqld.service - MySQL 5.7 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mysql57-mysqld.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 21 14:41:13 9b923d2bfd11 systemd[1]: Starting MySQL 5.7 database server...
Oct 21 14:41:13 9b923d2bfd11 scl[272]: Initializing MySQL database
Oct 21 14:41:23 9b923d2bfd11 systemd[1]: Started MySQL 5.7 database server.
Oct 21 14:41:47 9b923d2bfd11 systemd[1]: Stopping MySQL 5.7 database server...
Oct 21 14:41:49 9b923d2bfd11 systemd[1]: Stopped MySQL 5.7 database server.

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

# systemctl enable rh-mysql57-mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mysql57-mysqld.service to /usr/lib/systemd/system/rh-mysql57-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql57-mysqld.service              enabled
rh-mysql57-mysqld@.service             disabled
# systemctl disable rh-mysql57-mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-mysql57-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql57-mysqld.service              disabled
rh-mysql57-mysqld@.service             disabled

各種確認

# systemctl start rh-mysql57-mysqld
# mysql -u root -e 'select version();'
+-----------+
| version() |
+-----------+
| 5.7.24    |
+-----------+
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?