1 views

実現する機能

会社の財産は多くの場合データで、データは多くの場合、電算システムのデータベースサーバーに格納されています。ここでは、無料のデータベースサーバーの中から、MariaDBの導入手順を紹介します。

事前準備(下記サイトで確認のこと)

MariaDBの導入手順

TeraTermでコマンドを使う方法を理解しておくこと。以下の記述ではTeraTerm画面を表示しています。紫色はキーボードから入力するコマンド(コピペした方が楽ですが、コマンドは覚えられません)、緑はコマンドや処理内容の説明、白は自動表示する部分、赤は注意書きです。

(1)MariaDBのインストール

以下の黒背景部分はGNOME端末を表示しています。紫色はキーボードから入力するコマンド(コピペした方が楽ですが、コマンドは覚えられません)、緑はコマンドや処理内容の説明、白は自動表示する部分、赤は注意書きです。

#mariadb-serverをSCLoからインストール

[root@eycwl8s4 ~]# yum --enablerepo=centos-sclo-rh -y install rh-mariadb101-mariadb-server

Loaded plugins: fastestmirror, priorities


Installed:
rh-mariadb101-mariadb-server.x86_64 1:10.1.29-3.el7

Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7


setools-libs.x86_64 0:3.3.8-4.el7

Complete!

(2)MariaDBの設定と起動

#rh-mariadb101を利用可能にする
[root@eycwl8s4 ~]# scl enable rh-mariadb101 bash

#mysqlのバージョン確認
[root@eycwl8s4 ~]# mysql -V
mysql Ver 15.1 Distrib 10.1.29-MariaDB, for Linux (x86_64) using EditLine wrapper

#mysqlの場所の確認
[root@eycwl8s4 ~]# which mysql
/opt/rh/rh-mariadb101/root/usr/bin/mysql

#環境変数を読み込むシェルの作成
[root@eycwl8s4 ~]# vi /etc/profile.d/rh-mariadb101.sh
#以下の内容で新規作成

##!/bin/bash

source /opt/rh/rh-mariadb101/enable
export X_SCLS="`scl enable rh-mariadb101 'echo $X_SCLS'`"

#mariadb-server.cnfの編集
[root@eycwl8s4 ~]# vi /etc/opt/rh/rh-mariadb101/my.cnf.d/mariadb-server.cnf


[mysqld]
datadir=/var/opt/rh/rh-mariadb101/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/opt/rh/rh-mariadb101/log/mariadb/mariadb.log
pid-file=/var/run/rh-mariadb101-mariadb/mariadb.pid
#追記
character-set-server=utf8

#rh-mariadb101-mariadb起動
[root@eycwl8s4 ~]# systemctl start rh-mariadb101-mariadb

#rh-mariadb101-mariadb自動起動設定
[root@eycwl8s4 ~]# systemctl enable rh-mariadb101-mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mariadb101-mariadb.service to /usr/lib/systemd/system/rh-mariadb101-mariadb.service.

(3)MariaDBの動作確認

#MySQLのInstall
[root@eycwl8s4 ~]# 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キー押下
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.
#rootのパスワード作成でy入力
Set root password? [Y/n] y
#rootのパスワード作成
New password:
#rootのパスワード再入力
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.
#匿名ユーザーの削除でy入力
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.
#rootでのログイン禁止でy入力
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.
#testデータベースの削除でy入力
Remove test database and access to it? [Y/n] 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.
#権限テーブルの更新でy入力
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!

#設定したrootパスワードでログイン
[root@eycwl8s4 ~]# mysql -u root -p
#rootパスワード入力しEnterキー押下
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.1.29-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)]> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | ***************************************** |
| root | 127.0.0.1 | ***************************************** |
| root | ::1       | ***************************************** |
+------+-----------+-------------------------------------------+

3 rows in set (0.00 sec)

#MySQLの終了
MariaDB [(none)]> exit
Bye

[root@eycwl8s4 ~]#

以上

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください