CentOS6系にMySQL5.7をインストールしたい
何も考えずに、とりあえずMySQL5.7のリポジトリを追加するために
yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
上記コマンドでリポジトリを追加しました。
その後、
yum install mysql-community-server
このコマンドを実行します。
しかし、勘の良い方はここでお気付きかもしれませんが、これでは上手くいきません。
CentOS6系は
mysql57-community-release-el7-11.noarch.rpm
このel-7
の部分がel-6
でなければいけません。
案の定転んだので色々と調べて回ったところ、どうやら最近はMySQL公式のyumリポジトリに過去の5.7や5.6のリポジトリも含まれているようなので、素直に公式からリポジトリを追加します。
先ほど追加したリポジトリは
rpm -qa | grep mysql
上記コマンドでMySQLのリポジトリ情報を表示して、
rpm -e mysql57-community-release-el7-11.noarch.rpm
上記コマンドでアンインストールしました。
MySQL公式リポジトリ追加
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
上記コマンドでリポジトリ追加後、下記コマンドで追加されているかを確認します。
rpm -qa | grep mysql
mysql80-community-release-el6-1.noarch
無事追加されたので、ここからインストールしたいバージョンのリポジトリを有効にします。
vi /etc/yum.repos.d/mysql-community.repo
上記ファイルを開いて
# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
この8.0のenabledを0
にし、5.7のenabledを1
に変更しました。
その後、下記コマンドを叩きます。
yum repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community 59
mysql-tools-community MySQL Tools Community 65
mysql57-community MySQL 5.7 Community Server 273
無事5.7を向いていることが確認できました。
ここでyum install mysql-community-server
を叩いたのですが…
エラー: パッケージ: mysql-community-server-5.7.23-1.el7.x86_64 (mysql57-community)
要求: systemd
エラー: パッケージ: mysql-community-client-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libc.so.6(GLIBC_2.14)(64bit)
エラー: パッケージ: mysql-community-server-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libsasl2.so.3()(64bit)
エラー: パッケージ: mysql-community-server-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libc.so.6(GLIBC_2.17)(64bit)
エラー: パッケージ: mysql-community-client-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
エラー: パッケージ: mysql-community-libs-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libc.so.6(GLIBC_2.14)(64bit)
エラー: パッケージ: mysql-community-server-5.7.23-1.el7.x86_64 (mysql57-community)
要求: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
問題を回避するために --skip-broken を用いることができません
これらを試行できます: rpm -Va --nofiles --nodigest
おや?と思い、mysql-community-serverの情報を見てみると
利用可能なパッケージ
名前 : mysql-community-server
アーキテクチャ : x86_64
バージョン : 5.7.23
リリース : 1.el7
容量 : 165 M
リポジトリー : mysql57-community
要約 : A very fast and reliable SQL database server
URL : http://www.mysql.com/
ライセンス : Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
: Under GPLv2 license as shown in the Description field.
説明 : 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.
リリース : 1.el7
…🤔
CentOS6系なので、ここはel6
でないといけないはず…
もしかしてキャッシュが悪さしているのでは?と思ったので、yum clean all
を実行。
再度yum info mysql-community-server
を実行すると…
利用可能なパッケージ
名前 : mysql-community-server
アーキテクチャ : x86_64
バージョン : 5.7.23
リリース : 1.el6
容量 : 153 M
リポジトリー : mysql57-community
要約 : A very fast and reliable SQL database server
URL : http://www.mysql.com/
ライセンス : Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
: Under GPLv2 license as shown in the Description field.
説明 : 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.
無事にel6
になりました。
あとはyum install mysql-community-server
を叩いてやれば、無事にMySQL5.7のインストールが完了します。
ネットを調べても「リポジトリが違うからインストールミスるんだよ」みたいな解決法しかなく、しばらく路頭に迷っていたので、上手くいかない方はキャッシュクリアをお試しください。