今更ですが、仕事で必要になったのでメモとして記事にします。
環境
以下の環境でテストしています。
- OS
- Windows 10 Pro (20H2)
- VM
- VirtualBox 6.1.16
- Vagrant 2.2.13
- Vagrant Box
- bento/centos-7 (202103.18.0)
コマンド
最初はデフォルトで入っているMariaDB関連の削除から。
[root@localhost vagrant]# rpm -qa | grep -i mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost vagrant]# yum remove mariadb-libs
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-9.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Removing:
mariadb-libs x86_64 1:5.5.68-1.el7 @anaconda 4.4 M
Removing for dependencies:
postfix x86_64 2:2.10.1-9.el7 @anaconda 12 M
Transaction Summary
========================================================================================================================
Remove 1 Package (+1 Dependent package)
Installed size: 17 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 2:postfix-2.10.1-9.el7.x86_64 1/2
Erasing : 1:mariadb-libs-5.5.68-1.el7.x86_64 2/2
Verifying : 1:mariadb-libs-5.5.68-1.el7.x86_64 1/2
Verifying : 2:postfix-2.10.1-9.el7.x86_64 2/2
Removed:
mariadb-libs.x86_64 1:5.5.68-1.el7
Dependency Removed:
postfix.x86_64 2:2.10.1-9.el7
Complete!
[root@localhost vagrant]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/usr/lib64/mysql
[root@localhost vagrant]# find / -name mariadb
[root@localhost vagrant]#
お次はリポジトリの追加です。
[root@localhost vagrant]# yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
Loaded plugins: fastestmirror
mysql57-community-release-el6-7.noarch.rpm | 8.6 kB 00:00:00
Examining /var/tmp/yum-root-8VgFBQ/mysql57-community-release-el6-7.noarch.rpm: mysql57-community-release-el6-7.noarch
Marking /var/tmp/yum-root-8VgFBQ/mysql57-community-release-el6-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el6-7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
mysql57-community-release noarch el6-7 /mysql57-community-release-el6-7.noarch 7.8 k
Transaction Summary
========================================================================================================================
Install 1 Package
Total size: 7.8 k
Installed size: 7.8 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql57-community-release-el6-7.noarch 1/1
Verifying : mysql57-community-release-el6-7.noarch 1/1
Installed:
mysql57-community-release.noarch 0:el6-7
Complete!
リポジトリの確認と切り替えです。
[root@localhost vagrant]# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 161
mysql-connectors-community-source MySQL Connectors Community - disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 102
mysql-tools-community-source MySQL Tools Community - Sour disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 468
mysql57-community-source MySQL 5.7 Community Server - disabled
[root@localhost vagrant]# yum-config-manager --disable mysql57-community
Loaded plugins: fastestmirror
=============================================== repo: mysql57-community ================================================
[mysql57-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7/mysql57-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 0
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/7/mysql57-community/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = MySQL 5.7 Community Server
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7/mysql57-community
pkgdir = /var/cache/yum/x86_64/7/mysql57-community/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = mysql57-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
[root@localhost vagrant]# yum-config-manager --enable mysql56-community
Loaded plugins: fastestmirror
=============================================== repo: mysql56-community ================================================
[mysql56-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7/mysql56-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 1
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/mysql56-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/mysql56-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/7/mysql56-community/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = MySQL 5.6 Community Server
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7/mysql56-community
pkgdir = /var/cache/yum/x86_64/7/mysql56-community/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = mysql56-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
[root@localhost vagrant]# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 161
mysql-connectors-community-source MySQL Connectors Community - disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 102
mysql-tools-community-source MySQL Tools Community - Sour disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server enabled: 644
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community/x86_64 MySQL 5.7 Community Server disabled
mysql57-community-source MySQL 5.7 Community Server - disabled
[root@localhost vagrant]#
MySQL5.6をインストールします。
[root@localhost vagrant]# yum install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.jaist.ac.jp
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.51-2.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.51-2.el6 for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.51-2.el6.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mysql-community-client.x86_64 0:5.6.51-2.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.51-2.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.6.51-2.el6 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.51-2.el6 will be installed
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================== Package Arch Version Repository Size
========================================================================================================================Installing:
mysql-community-server x86_64 5.6.51-2.el6 mysql56-community 62 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
mysql-community-client x86_64 5.6.51-2.el6 mysql56-community 20 M
mysql-community-common x86_64 5.6.51-2.el6 mysql56-community 340 k
mysql-community-libs x86_64 5.6.51-2.el6 mysql56-community 2.2 M
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
Transaction Summary
========================================================================================================================Install 1 Package (+11 Dependent packages)
Total download size: 86 M
Installed size: 355 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-client-5.6.51-2.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-client-5.6.51-2.el6.x86_64.rpm is not installed
(1/12): mysql-community-client-5.6.51-2.el6.x86_64.rpm | 20 MB 00:00:00
(2/12): mysql-community-common-5.6.51-2.el6.x86_64.rpm | 340 kB 00:00:00
(3/12): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
(4/12): mysql-community-libs-5.6.51-2.el6.x86_64.rpm | 2.2 MB 00:00:00
(5/12): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(6/12): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(7/12): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(8/12): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(9/12): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(10/12): mysql-community-server-5.6.51-2.el6.x86_64.rpm | 62 MB 00:00:01
(11/12): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(12/12): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------Total 52 MB/s | 86 MB 00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el6-7.noarch (@/mysql57-community-release-el6-7.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.6.51-2.el6.x86_64 1/12
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/12
Installing : mysql-community-libs-5.6.51-2.el6.x86_64 3/12
Installing : mysql-community-client-5.6.51-2.el6.x86_64 4/12
Installing : libaio-0.3.109-13.el7.x86_64 5/12
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 6/12
Installing : perl-Net-Daemon-0.48-5.el7.noarch 7/12
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 8/12
Installing : perl-IO-Compress-2.061-2.el7.noarch 9/12
Installing : perl-PlRPC-0.2020-14.el7.noarch 10/12
Installing : perl-DBI-1.627-4.el7.x86_64 11/12
Installing : mysql-community-server-5.6.51-2.el6.x86_64 12/12
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 1/12
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 2/12
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 3/12
Verifying : mysql-community-server-5.6.51-2.el6.x86_64 4/12
Verifying : mysql-community-common-5.6.51-2.el6.x86_64 5/12
Verifying : perl-IO-Compress-2.061-2.el7.noarch 6/12
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/12
Verifying : mysql-community-libs-5.6.51-2.el6.x86_64 8/12
Verifying : mysql-community-client-5.6.51-2.el6.x86_64 9/12
Verifying : perl-DBI-1.627-4.el7.x86_64 10/12
Verifying : libaio-0.3.109-13.el7.x86_64 11/12
Verifying : perl-PlRPC-0.2020-14.el7.noarch 12/12
Installed:
mysql-community-server.x86_64 0:5.6.51-2.el6
Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:5.6.51-2.el6
mysql-community-common.x86_64 0:5.6.51-2.el6 mysql-community-libs.x86_64 0:5.6.51-2.el6
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7
Complete!
[root@localhost vagrant]#
確認します。
[root@localhost vagrant]# systemctl status mysqld
● mysqld.service - SYSV: MySQL database server.
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
[root@localhost vagrant]# systemctl start mysqld
[root@localhost vagrant]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> ^DBye
自動起動をオンにします。
[root@localhost vagrant]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@localhost vagrant]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
とりあえずこれでOK。