1 views

UPdate:2022.01.07

実現する機能

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

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

MariaDBの導入手順

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

(1)MariaDBのrepositoryの取得

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

mo
#mariadbのmodule listを確認
[root@eycwl8s4 ~]# dnf module list mariadb
CentOS Stream 8 – AppStream
Name Stream Profiles Summary
mariadb 10.3 [d] client, galera, server [d] MariaDB Module
mariadb 10.5 client, galera, server [d] MariaDB Module

ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled

#mariadb 10.5のInstall
[root@eycwl8s4 ~]# dnf module install mariadb:10.5 -y
インストール済み:
mariadb-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-backup-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-common-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-connector-c-3.1.11-2.el8_3.x86_64
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
mariadb-errmsg-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-gssapi-server-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-server-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mariadb-server-utils-3:10.5.9-1.module_el8.5.0+732+7afc82e7.x86_64
mysql-selinux-1.0.2-4.el8.noarch
perl-DBD-MySQL-4.046-3.module_el8.3.0+419+c2dec72b.x86_64

完了しました!

#mariadb 10.5の自動起動設定
[root@eycwl8s4 ~]# systemctl enable –now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

(2)MariaDBのSetup

#MariaDBのsetup
[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
haven’t set the root password yet, 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 or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer ‘n’.
#rootのパスワードをOSのrootと統合するか?と解釈してn入力
Switch to unix_socket authentication [Y/n] n
… skipping.

You already have your root account protected, so you can safely answer ‘n’.

Change the root password? [Y/n] y
New password: ← rootのパスワード作成
Re-enter new password: ← rootのパスワード再入力
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 databaseの削除に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!

#MariaDBの起動
[root@eycwl8s4 ~]# mysql -u root -p
#mariadb用のrootパスワード入力しEnterキー押下
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
#MySQLの終了
MariaDB [(none)]> exit
Bye

#mariadb-server.cnfの編集
[root@eycwl8s4 ~]# vi /etc/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
#追記
[mysqld]
character-set-server = utf8mb4

[client]
default-character-set = utf8mb4

#mariadb再起動
[root@eycwl8s4 ~]# systemctl restart mariadb

以上

コメントを残す

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

CAPTCHA


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