LoginSignup
14
8

More than 5 years have passed since last update.

CentOS6系にMySQL5.7をインストールした際につまずいたこと

Last updated at Posted at 2018-09-24

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のインストールが完了します。

ネットを調べても「リポジトリが違うからインストールミスるんだよ」みたいな解決法しかなく、しばらく路頭に迷っていたので、上手くいかない方はキャッシュクリアをお試しください。

14
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
8