CentOS8.2にMySQL5.7をインストールする

CentOS8.2にMySQL5.7をインストールしようとしたら、mysql-community-serverが無かったので調べてみたらCentOS7系とは少しやり方が違ったので忘却防止のため記録。

MySQL5.7のリポジトリの有効化

RPMファイルをインストールします

# yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

yum-utilsをインストールします

# yum install yum-utils
MySQL 8.0 Community Server 55 MB/s | 1.3 MB 00:00
MySQL Connectors Community 4.4 MB/s | 79 kB 00:00
MySQL Tools Community 28 MB/s | 476 kB 00:00
Package yum-utils-4.0.12-4.el8_2.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

全リポジトリのリストを確認するとデフォルトではmysql80-communityが有効になっているので、これを無効にしてmysql57-communityを有効にします

# yum repolist all
repo id repo name status
AppStream CentOS-8 - AppStream enabled
AppStream-source CentOS-8 - AppStream Sources disabled
BaseOS CentOS-8 - Base enabled
BaseOS-source CentOS-8 - BaseOS Sources disabled
Devel CentOS-8 - Devel WARNING! FOR BUILDROOT USE ONLY! disabled
HighAvailability CentOS-8 - HA disabled
PowerTools CentOS-8 - PowerTools disabled
base-debuginfo CentOS-8 - Debuginfo disabled
c8-media-AppStream CentOS-AppStream-8 - Media disabled
c8-media-BaseOS CentOS-BaseOS-8 - Media disabled
centosplus CentOS-8 - Plus disabled
centosplus-source CentOS-8 - Plus Sources disabled
cr CentOS-8 - cr disabled
extras CentOS-8 - Extras enabled
extras-source CentOS-8 - Extras Sources disabled
fasttrack CentOS-8 - fasttrack disabled
mysql-cluster-7.5-community MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - Source disabled
mysql-cluster-7.6-community MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Source disabled
mysql-cluster-8.0-community MySQL Cluster 8.0 Community disabled
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - Source disabled
mysql-connectors-community MySQL Connectors Community enabled
mysql-connectors-community-source MySQL Connectors Community - Source disabled
mysql-tools-community MySQL Tools Community enabled
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - Source disabled
mysql56-community MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - Source disabled
mysql57-community MySQL 5.7 Community Server enabled
mysql57-community-source MySQL 5.7 Community Server - Source disabled
mysql80-community MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - Source disabled
openlogic CentOS-8 - openlogic packages for x86_64 enabled

mysql80-communityを無効にしてmysql57-communityを有効にします

# yum-config-manager --disable mysql80-community
# yum-config-manager --enable mysql57-community
# yum clean all

mysql57-communityが有効になっているか確認します

# yum repolist enabled
repo id repo name
AppStream CentOS-8 - AppStream
BaseOS CentOS-8 - Base
extras CentOS-8 - Extras
mysql-connectors-community MySQL Connectors Community
mysql-tools-community MySQL Tools Community
mysql57-community MySQL 5.7 Community Server
openlogic CentOS-8 - openlogic packages for x86_64

mysqlとmariadbのモジュール確認をします

# yum module list mysql mariadb
Last metadata expiration check: 0:05:37 ago on Thu 15 Oct 2020 01:04:34 PM JST.
CentOS-8 - AppStream
Name Stream Profiles Summary
mariadb 10.3 [d] client, galera, server [d] MariaDB Module
mysql 8.0 [d] client, server [d] MySQL Module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

mysqlとmariadbのモジュール状態を確認してみると[d](default)になってなっているのでmysqlとmariadbモジュールを無効にします

# yum module disable mysql mariadb
Last metadata expiration check: 0:05:50 ago on Thu 15 Oct 2020 01:04:34 PM JST.
Dependencies resolved.
================================================================================================================================================================================================
Package Architecture Version Repository Size
================================================================================================================================================================================================
Disabling modules:
mariadb
mysql

Transaction Summary
================================================================================================================================================================================================

Is this ok [y/N]: y
Complete!

再度mysqlとmariadbのモジュール確認すると[x](disabled)になっていることを確認します

# yum module list mysql mariadb
Last metadata expiration check: 0:06:01 ago on Thu 15 Oct 2020 01:04:34 PM JST.
CentOS-8 - AppStream
Name Stream Profiles Summary
mariadb 10.3 [d][x] client, galera, server [d] MariaDB Module
mysql 8.0 [d][x] client, server [d] MySQL Module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

mysql-community-serverの情報を確認してみるとmysql-community-serverも存在し、MySQL5.7が有効になっています

# yum info mysql-community-server
Last metadata expiration check: 0:06:27 ago on Thu 15 Oct 2020 01:04:34 PM JST.
Available Packages
Name : mysql-community-server
Version : 5.7.31
Release : 1.el7
Architecture : x86_64
Size : 173 M
Source : mysql-community-5.7.31-1.el7.src.rpm
Repository : mysql57-community
Summary : A very fast and reliable SQL database server
URL : http://www.mysql.com/
License : Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
Description : The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
: and robust SQL (Structured Query Language) database server. MySQL Server
: is intended for mission-critical, heavy-load production systems as well
: as for embedding into mass-deployed software. MySQL is a trademark of
: Oracle and/or its affiliates
:
: The MySQL software has Dual Licensing, which means you can use the MySQL
: software free of charge under the GNU General Public License
: (http://www.gnu.org/licenses/). You can also purchase commercial MySQL
: licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
: the GPL. See the chapter "Licensing and Support" in the manual for
: further info.
:
: The MySQL web site (http://www.mysql.com/) provides the latest news and
: information about the MySQL software. Also please see the documentation
: and the manual for more information.
:
: This package includes the MySQL server binary as well as related utilities
: to run and administer a MySQL server.

MySQL5.7をインストール

mysql-community-serverをインストールします

# yum install mysql-community-server

MySQL5.7がインストールされているか確認します

# rpm -qa | grep mysql
mysql80-community-release-el7-3.noarch
mysql-community-common-5.7.31-1.el7.x86_64
mysql-community-libs-5.7.31-1.el7.x86_64
mysql-community-client-5.7.31-1.el7.x86_64
mysql-community-server-5.7.31-1.el7.x86_64

MySQL5.7の有効化と起動

# systemctl enable mysqld
# systemctl start mysqld

初期パスワードを調べます

# grep 'temporary password' /var/log/mysqld.log
2020-10-15T04:55:21.482474Z 1 [Note] A temporary password is generated for root@localhost: **********

初期設定を行い、パスワードを変更します

# mysql_secure_installation

MySQLのバージョンを確認する

# mysql -u root -p -e "select version()"
Enter password:
+-----------+
| version() |
+-----------+
| 5.7.31 |
+-----------+

 

 

end