CentOS7.3 MariaDB10.2.6のインストール

シェアする

MariaDB10.2.6のインストール方法です。

MariaDB10.2のリポジトリー設定

MariaDB10系は、CentOS7.3の公式リポジトリーにありませんでしたので、MariaDBの公式リポジトリーからダウンロードします。

MariaDBの公式リポジトリーの情報は、下記のURLにアクセスして、目的のrepoファイルを作成します。

https://downloads.mariadb.org/mariadb/repositories/

1. Choose a Distro => CentOS
2. Choose a Release => CentOS 7 (x86_64)
3. Choose a Version => 10.2 [Stable]

サイト上に、repoファイルの内容が表示されるので、それをサンプルにしてrepoファイルを作成します。

# vim /etc/yum.repos.d/mariadb.repo <LF>
# MariaDB 10.2 CentOS repository list - created 2017-05-25 08:12 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

MariaDB5.5系のパッケージを削除

MariaDB5.5系のパッケージがOS最小構成インストールでも入っているので削除します。

# yum info mariadb-libs.x86_64 <LF>
    :
Installed Packages
Name        : mariadb-libs
Arch        : x86_64
Epoch       : 1
Version     : 5.5.52
Release     : 1.el7
Size        : 4.4 M
Repo        : installed
From repo   : anaconda
Summary     : The shared libraries required for MariaDB/MySQL clients
    :
# yum -y remove mariadb-libs.x86_64 <LF>
    :
Removed:
  mariadb-libs.x86_64 1:5.5.52-1.el7
 
Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7
 
Complete!

MariaDB10.2のインストール

ここからは、今までと変わらない方法でインストールします。

# yum list | grep Maria <LF>
MariaDB-aws-key-management.x86_64          10.2.6-1.el7.centos         mariadb
MariaDB-backup.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-client.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-common.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-compat.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-connect-engine.x86_64              10.2.6-1.el7.centos         mariadb
MariaDB-cracklib-password-check.x86_64     10.2.6-1.el7.centos         mariadb
MariaDB-devel.x86_64                       10.2.6-1.el7.centos         mariadb
MariaDB-gssapi-server.x86_64               10.2.6-1.el7.centos         mariadb
MariaDB-oqgraph-engine.x86_64              10.2.6-1.el7.centos         mariadb
MariaDB-rocksdb-engine.x86_64              10.2.6-1.el7.centos         mariadb
MariaDB-server.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-shared.x86_64                      10.2.6-1.el7.centos         mariadb
MariaDB-test.x86_64                        10.2.6-1.el7.centos         mariadb
MariaDB-tokudb-engine.x86_64               10.2.6-1.el7.centos         mariadb
# yum -y install MariaDB-server MariaDB-client <LF>
    :
Installed:
  MariaDB-client.x86_64 0:10.2.6-1.el7.centos
  MariaDB-server.x86_64 0:10.2.6-1.el7.centos
 
Dependency Installed:
  MariaDB-common.x86_64 0:10.2.6-1.el7.centos
  MariaDB-compat.x86_64 0:10.2.6-1.el7.centos
  boost-program-options.x86_64 0:1.53.0-26.el7
  galera.x86_64 0:25.3.20-1.rhel7.el7.centos
  lsof.x86_64 0:4.87-4.el7
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7
  rsync.x86_64 0:3.0.9-17.el7
 
Complete!

初期設定変更

文字コードはUTF-8で、問題ないでしょう。

# cd /etc/my.cnf.d <LF>
# cp -p server.cnf server.cnf.original <LF>
# sed -i '/^\[mysqld\]$/a character-set-server=utf8' server.cnf <LF>

MariaDBを起動して、いつもの初期設定を行ないます。

# systemctl start mariadb <LF>
# mysql_secure_installation <LF>
 
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):<LF> <= 空エンター
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 <LF>
New password:rootpass
Re-enter new password:rootpass
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 <LF>
 ... 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 <LF>
 ... 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 <LF>
 - 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? [Y/n] y <LF>
 ... 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 -u root -p <LF>
Enter password:rootpass
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.2.6-MariaDB MariaDB Server
 
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
 
MariaDB [(none)]> exit
Bye