CentOS 7에 MySQL 8.0 설치(SCL)

CentOS 7에 MySQL 8.0 설치(SCL)

2022-10-05 last update

6 minutes reading MySQL scl centos7

소개



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
[email protected]             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
[email protected]             disabled

각종 확인


# systemctl start rh-mysql80-mysqld
# mysql -u root -e 'select version();'
+-----------+
| version() |
+-----------+
| 8.0.17    |
+-----------+