今回は、Amazon Linux2のEC2インスタンスからRDSへ接続するために、MySQLのclientだけをインストールする手順を紹介します。
何気にクライアントだけというのは紹介がないため、覚えておくと便利かと思います。
ちなみに環境は以下の通りです。
- EC2:Amazon Linux2
- RDS :MySQL 8.0.20
1.MySQL8.0のリポジトリの追加
- yum infoコマンドでmysql関連がないことを確認
- リポジトリの追加
$ sudo yum info mysql
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
191 packages excluded due to repository priority protections
Error: No matching Packages to list
$
$ sudo yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
mysql80-community-release-el7-3.noarch.rpm | 25 kB 00:00
Examining /var/tmp/yum-root-1tmiU9/mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch
Marking /var/tmp/yum-root-1tmiU9/mysql80-community-release-el7-3.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-3 will be installed
--> Finished Dependency Resolution
amzn2-core/2/x86_64 | 3.7 kB 00:00
Dependencies Resolved
================================================================================
Package Arch Version
Repository Size
================================================================================
Installing:
mysql80-community-release
noarch el7-3 /mysql80-community-release-el7-3.noarch 31 k
Transaction Summary
================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql80-community-release-el7-3.noarch 1/1
Verifying : mysql80-community-release-el7-3.noarch 1/1
Installed:
mysql80-community-release.noarch 0:el7-3
Complete!
2.MySQL8.0のリポジトリの有効化
- MySQL5.7も入っているため、8.0のリポジトリを有効化します
$ sudo yum-config-manager --disable mysql57-community
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
=========================== repo: mysql57-community ============================
[mysql57-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/2
baseurl = http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/2/mysql57-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = False
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/2/mysql57-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/2/mysql57-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/2/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/2/mysql57-community
pkgdir = /var/cache/yum/x86_64/2/mysql57-community/packages
priority = 99
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
report_instanceid = False
retries = 7
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 5.0
ui_id = mysql57-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
$
$ sudo yum-config-manager --enable mysql80-community
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
=========================== repo: mysql80-community ============================
[mysql80-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/2
baseurl = http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/2/mysql80-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = True
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/2/mysql80-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/2/mysql80-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/2/mysql80-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 8.0 Community Server
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/2/mysql80-community
pkgdir = /var/cache/yum/x86_64/2/mysql80-community/packages
priority = 99
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
report_instanceid = False
retries = 7
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 5.0
ui_id = mysql80-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
3.mysql-community-clientのインストール
- mysql-community-clientをインストール
- mysqlコマンドが実行できるか確認
$ sudo yum install -y mysql-community-client
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql80-community | 2.5 kB 00:00
226 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.21-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.21-1.el7.x86_64
--> Processing Dependency: libtinfo.so.5()(64bit) for package: mysql-community-client-8.0.21-1.el7.x86_64
--> Processing Dependency: libncurses.so.5()(64bit) for package: mysql-community-client-8.0.21-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.64-1.amzn2 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.amzn2.0.3.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.amzn2.0.3.x86_64
---> Package mysql-community-libs.x86_64 0:8.0.21-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) >= 8.0.11 for package: mysql-community-libs-8.0.21-1.el7.x86_64
---> Package ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 will be installed
--> Running transaction check
---> Package mysql-community-common.x86_64 0:8.0.21-1.el7 will be installed
---> Package mysql-community-libs-compat.x86_64 0:8.0.21-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql-community-client x86_64 8.0.21-1.el7 mysql80-community 48 M
mysql-community-libs x86_64 8.0.21-1.el7 mysql80-community 4.5 M
replacing mariadb-libs.x86_64 1:5.5.64-1.amzn2
mysql-community-libs-compat
x86_64 8.0.21-1.el7 mysql80-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.64-1.amzn2
Installing for dependencies:
mysql-community-common x86_64 8.0.21-1.el7 mysql80-community 617 k
ncurses-compat-libs x86_64 6.0-8.20170212.amzn2.1.3 amzn2-core 308 k
Transaction Summary
================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 54 M
Downloading packages:
warning: /var/cache/yum/x86_64/2/mysql80-community/packages/mysql-community-common-8.0.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-8.0.21-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-8.0.21-1.el7.x86_64.rpm | 617 kB 00:00
(2/5): mysql-community-libs-8.0.21-1.el7.x86_64.rpm | 4.5 MB 00:00
(3/5): mysql-community-libs-compat-8.0.21-1.el7.x86_64.rpm | 1.2 MB 00:00
(4/5): ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64 | 308 kB 00:00
(5/5): mysql-community-client-8.0.21-1.el7.x86_64.rpm | 48 MB 00:00
--------------------------------------------------------------------------------
Total 69 MB/s | 54 MB 00:00
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 : mysql80-community-release-el7-3.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-8.0.21-1.el7.x86_64 1/6
Installing : mysql-community-libs-8.0.21-1.el7.x86_64 2/6
Installing : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64 3/6
Installing : mysql-community-client-8.0.21-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-8.0.21-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.64-1.amzn2.x86_64 6/6
Verifying : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64 1/6
Verifying : mysql-community-libs-8.0.21-1.el7.x86_64 2/6
Verifying : mysql-community-client-8.0.21-1.el7.x86_64 3/6
Verifying : mysql-community-libs-compat-8.0.21-1.el7.x86_64 4/6
Verifying : mysql-community-common-8.0.21-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.64-1.amzn2.x86_64 6/6
Installed:
mysql-community-client.x86_64 0:8.0.21-1.el7
mysql-community-libs.x86_64 0:8.0.21-1.el7
mysql-community-libs-compat.x86_64 0:8.0.21-1.el7
Dependency Installed:
mysql-community-common.x86_64 0:8.0.21-1.el7
ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3
Replaced:
mariadb-libs.x86_64 1:5.5.64-1.amzn2
Complete!
$
$ mysql --version
mysql Ver 8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)
完了です。
(参考・引用元)https://aws.amazon.com/jp/
コメント
コメントを投稿