LoginSignup
5
6

More than 5 years have passed since last update.

yum経由のMySQL8.0の初期インストール@CentOS6.x

Last updated at Posted at 2016-11-04

何番煎じかわかりませんが、CentOS6.x上に先日公開されたMySQL8.0をyum経由でインストールできる手順を確かめてみました。細かくて見落としがちな項目も少しありますので、覚書として確認してみては如何でしょうか?

レポジトリのrpmファイルをMySQL communityからインストール

[root@cent6 ~]# rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

mysql-community.repoの編集(5.7→8.0への変更)

/etc/yum.repos.d/mysql-community.repo

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0 ← 無効にするために"0"に変更
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=1 ← 有効にするために"1"に変更
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

利用可能なパッケージとしての確認

[root@cent6 ~]# yum info mysql-community-server
読み込んだプラグイン:fastestmirror, security
Determining fastest mirrors
mysql-connectors-community                                                                       | 2.5 kB     00:00
mysql-connectors-community/primary_db                                                            |  11 kB     00:00
mysql-tools-community                                                                            | 2.5 kB     00:00
mysql-tools-community/primary_db                                                                 |  32 kB     00:00
mysql80-community                                                                                | 2.5 kB     00:00
mysql80-community/primary_db                                                                     |  17 kB     00:00
利用可能なパッケージ
名前                : mysql-community-server
アーキテクチャ      : x86_64
バージョン          : 8.0.0
リリース            : 0.1.dmr.el6
容量                : 196 M
リポジトリー        : mysql80-community
要約                : A very fast and reliable SQL database server
URL                 : http://www.mysql.com/
ライセンス          : Copyright (c) 2000, 2016, 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.

yum経由でのインストール

[root@cent6 ~]# yum install mysql-community-server
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package mysql-community-server.x86_64 0:8.0.0-0.1.dmr.el6 will be インストール
--> 依存性の処理をしています: mysql-community-common(x86-64) = 8.0.0-0.1.dmr.el6 のパッケージ: mysql-community-server-8.0.0-0.1.dmr.el6.x86_64
--> 依存性の処理をしています: mysql-community-client(x86-64) >= 8.0.0 のパッケージ: mysql-community-server-8.0.0-0.1.dmr.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package mysql-community-client.x86_64 0:8.0.0-0.1.dmr.el6 will be インストール
--> 依存性の処理をしています: mysql-community-libs(x86-64) >= 8.0.0 のパッケージ: mysql-community-client-8.0.0-0.1.dmr.el6.x86_64
---> Package mysql-community-common.x86_64 0:8.0.0-0.1.dmr.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package mysql-community-libs.x86_64 0:8.0.0-0.1.dmr.el6 will be obsoleting
---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be 不要
--> 依存性の処理をしています: libmysqlclient.so.16()(64bit) のパッケージ: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> 依存性の処理をしています: libmysqlclient.so.16(libmysqlclient_16)(64bit) のパッケージ: 2:postfix-2.6.6-6.el6_7.1.x86_64
--> トランザクションの確認を実行しています。
---> Package mysql-community-libs-compat.x86_64 0:8.0.0-0.1.dmr.el6 will be obsoleting
--> 依存性解決を終了しました。

依存性を解決しました

========================================================================================================================
 パッケージ                            アーキテクチャ   バージョン                    リポジトリー                 容量
========================================================================================================================
インストールしています:
 mysql-community-libs                  x86_64           8.0.0-0.1.dmr.el6             mysql80-community           2.5 M
     置き換えています  mysql-libs.x86_64 5.1.73-7.el6
 mysql-community-libs-compat           x86_64           8.0.0-0.1.dmr.el6             mysql80-community           1.8 M
     置き換えています  mysql-libs.x86_64 5.1.73-7.el6
 mysql-community-server                x86_64           8.0.0-0.1.dmr.el6             mysql80-community           196 M
依存性関連でのインストールをします。:
 mysql-community-client                x86_64           8.0.0-0.1.dmr.el6             mysql80-community            27 M
 mysql-community-common                x86_64           8.0.0-0.1.dmr.el6             mysql80-community           335 k

トランザクションの要約
========================================================================================================================
インストール         5 パッケージ

総ダウンロード容量: 228 M
これでいいですか? [y/N]y

サービスの起動と自動起動設定の実施

[root@cent6 ~]# /etc/rc.d/init.d/mysqld start
MySQL データベースを初期化中:                              [  OK  ]
Installing validate password plugin:                       [  OK  ]
mysqld を起動中:                                           [  OK  ]
[root@cent6 ~]# chkconfig mysqld on

rootの初期パスワードの確認

意外とこの確認が抜けている為にrootでMySQLにログイン出来なかったりします。ご注意ください。

[root@cent6 ~]# cat /var/log/mysqld.log | grep 'temporary password'
2016-??-??T??:??:??.?????7Z ? [Note] A temporary password is generated for root@localhost: 'default-pass'

上記の'default-pass'が初期ログインパスワードです。

mysql_secure_installationの実施

セキュアなDB運用の最初の手順として、「rootユーザのパスワード変更」「"anonymous"ユーザの削除」「localhost外からアクセス可能なrootアカウントの削除」「testデータベースの削除」を行っておきましょう。またrootユーザの初期パスワード変更時、'validate_password'プラグインにて、強度の低いパスワードになっていないか、チェックしてくれる様です。

[root@cent6 ~]# mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

my.cnfの編集(やや重要)

サービス稼働時のデータベースにログインできなくなる"突然死"を防止の為です。パスワードの有効期限を無効にする為に「default_password_lifetime」の値を0に設定する事で問題回避を行います。

これはMySQL5.7以降で初期パラメータとして注意すべき問題となっている(2016年現時点で)ので、確認しておきましょう。

/etc/my.cnf
[mysqld]
default_password_lifetime = 0

(追記)
この値は2016/1/13の5.7.11から初期値としても0となっている様です。
http://www.slideshare.net/yoku0825/mysql-57449062
詳細は参照の程。

MySQLを再起動して設定の適用を行いましょう

[root@cent6 ~]# /etc/rc.d/init.d/mysqld restart

以上です。
また、my.cnfの設定変更は、初回の「/etc/rc.d/init.d/mysqld start」実行前に「my.cnf」にて適切に設定しましょう。

それでは良いMySQL運用ライフを!

5
6
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
5
6