MariaDBの方が良さげなのでMariaDBのインストール【カゴヤ・クラウド/VPSをいじる】

MySQLのインストール【カゴヤ・クラウド/VPSをいじる】
続きましてMySQLのインストールを行います。MariaDBのアンインストールCentOS7にはデータベースとしてMariaDBがインストールされているようです。別にMariaDBを動かしても特段問題はないのですが,純正MySQLの方が色々

昨日書いたとおり,MySQLアンインストール→MariaDBのインストールを行います。

きっかけ

きっかけはこのページを見たことでした。

http://readwrite.jp/archives/1018

2年前の記事なのですが,2年前からこんな動きを見せていたとは思ってもいませんでした。(インフラ系の情報収集不足ですね。反省。)

また,最近のディストリビューションはMariaDBをサポート,MySQLをサポート外にしているようです。

cocolog:@nifty

これだったらMariaDBですよね~。

MySQLのアンインストール

要するに昨日やったやつの逆を追えばよいのです。

#MySQLのアンインストール
[root@v0000 ~]# yum -y remove mysql
[root@v0000 ~]# yum -y remove mysql-devel
[root@v0000 ~]# yum -y remove mysql-server
[root@v0000 ~]# yum -y remove mysql-utilities

残っているかどうか調べます。

#MySQLものが残っているかどうかの確認
[root@v0000 ~]# yum list installed | grep mysql
mysql-community-common.x86_64        5.6.26-2.el7                   @mysql56-community
mysql-community-libs.x86_64          5.6.26-2.el7                   @mysql56-community
mysql-community-release.noarch       el7-5                          @/mysql-community-release-el7-5.noarch
mysql-connector-python.noarch        2.0.4-1.el7                    @mysql-connectors-community
php-mysqlnd.x86_64                   5.6.13-1.el7.remi              @remi-php56

まだ残っているので,片っ端から消していきます。(php-mysqlndはPHPのパッケージなのでアンインストールしません。)

#片っ端から消しています。
[root@v0000 ~]# yum -y remove mysql-community-common
[root@v0000 ~]# yum -y remove mysql-community-release.noarch
[root@v0000 ~]# yum -y remove mysql-connector-python.noarch

念のため確認です。

#消えているか確認
[root@v0000 ~]# yum list installed | grep mysql
php-mysqlnd.x86_64                   5.6.13-1.el7.remi              @remi-php56

消えております。これでインストール準備の完了です。

MariaDBのインストール

確かyumで入っているはずだから,みんな大好きyumでいけばいいんじゃないかと。

そのまえにyumリポジトリの追加です。

#yumリポジトリの追加
[root@v0000 ~]# nano /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

そしてインストールです。

#MariaDBのインストール
[root@v0000 ~]# yum -y install mariadb mariadb-server

いけました。

MariaDBの文字コードを設定しておきます。

#MariaDB設定ファイル編集
[root@v0000 ~]# nano /etc/my.cnf

[mysqld]
character-set-server = utf8
#追加(MariaDBサーバーの文字コードをUTF-8にする)

で,デーモンを起動するのですが,CentOS7からはsystemctlが使えるようになったとのことです。

systemctl enable|disabled で有効無効の切り替えが出来ます。

というわけで,MariaDBの確認をしていきます。

#mariadbの起動確認
[root@v0000 ~]# systemctl list-units |grep mariadb
#出力なしなので起動しておりません。

#mariadbのデーモンの登録状態の確認
[root@v0000 ~]# systemctl list-unit-files |grep mariadb
mariadb.service                        disabled
#無効になっております。

というわけでデーモン起動です。が,この環境ではsystemctl enableのみでいけそうです。

#mariadbの自動起動設定
[root@v0000 ~]# systemctl enable mariadb.service

#mariadbデーモンの登録状態の確認
[root@v0000 ~]# systemctl list-unit-files |grep mariadb
mariadb.service                        enabled

#reboot後に確認
[root@v0000 ~]# systemctl list-unit-files |grep mariadb
mariadb.service                        enabled
#大丈夫っぽい?

初期設定まで終わらせます。

とやっていたらうまくいきません。(異なる環境下だと大丈夫かもしれません。)

というわけで原始的にデーモン起動→自動起動設定です。

#mariadbデーモン起動
[root@v0000 ~]# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!

#mariadbデーモン自動起動設定からのチェック
[root@v2359 ~]# chkconfig mysql on
[root@v2359 ~]# chkconfig --list mysql

注記: この出力は SysV サービスのみであり、ネイティブな systemd のサービスは含まれていま せん。
      systemd services. SysV 設定のデータはネイティブな systemd の設定によって上書きされます。
      systemd サービスを一覧表示するには 'systemctl list-unit-files' を使用してください 。
      特定のターゲットにおいて有効化されているサービスを確認するには、
      'systemctl list-dependencies [target]' 。

mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

多分大丈夫でしょう(笑)

そして初期設定です。

#MariaDB初期設定
[root@v2359 ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): ←空エンター
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: ←パスワード入力
Re-enter new password: ←再度パスワード入力
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] 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? [Y/n] Y
 ... Success!

By default, MariaDB 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? [Y/n] Y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - 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? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

ようやく終了です。お疲れ様でした。

それもこれも

MySQLをインストールするからこんなに大変な目に遭ったわけです。

下調べ大事。

コメント