CentOS8.0にMariaDB10.3をインストールする手順を解説
MySQLと互換性のある「MariaDB」を、CentOS8へインストールして使ってみたいけれど、詳しい手順が分からない、と悩んでいませんか?
あと、インフラエンジニアになるためにおすすめの勉強法があれば知りたい、と考えていませんか?
CentOS8.0にMariaDB10.3をインストールしてみたときの手順を、コマンド付きで解説します
真似しながら進めれば、15分くらいで簡単にできます
本記事では、下記の内容を解説します。
- CentOS8へのMariaDB10.3 のインストール手順
- MariaDBの起動方法、自動起動の設定手順
- MariaDBのインストール後の基本設定手順
- MariDBのテストDB作成手順
- インフラエンジニアになるためのおススメの勉強法の紹介
この記事を書いている私は、某SIerに勤務しながら、WEB系エンジニア・インフラエンジニアに憧れて、
プログラミングおよびインフラ技術の勉強をしています。
私が実機で試したコマンドや画像を載せて書いていますので、記事の信頼性担保に繋がると思います。
前提条件
前回の記事で、CentOS8.0の基本設定およびファイアウォールfirewalldの設定が済んでいる状態です。
souiunogaii.hatenablog.comインストールする前のパッケージ確認
dnf list maria*
[root@SV-NEPTUNE ~]# dnf list maria* メタデータの期限切れの最終確認: 1:03:26 時間前の 2020年01月05日 09時42分38秒 に 実施しました。 インストール済みパッケージ mariadb-connector-c.x86_64 3.0.7-1.el8 @AppStream mariadb-connector-c-config.noarch 3.0.7-1.el8 @AppStream 利用可能なパッケージ mariadb.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-backup.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-common.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-connector-c.i686 3.0.7-1.el8 AppStream mariadb-connector-c-devel.i686 3.0.7-1.el8 AppStream mariadb-connector-c-devel.x86_64 3.0.7-1.el8 AppStream mariadb-connector-odbc.x86_64 3.0.7-1.el8 AppStream mariadb-devel.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-embedded.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-embedded-devel.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-errmsg.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-gssapi-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-java-client.noarch 2.2.5-2.el8 AppStream mariadb-oqgraph-engine.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-server-galera.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-server-utils.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream mariadb-test.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream
今回インストールするパッケージは3個
インストールする3個のパッケージ情報の確認
dnf info mariadb mariadb-server mariadb-devel
[root@SV-NEPTUNE ~]# dnf info mariadb mariadb-server mariadb-devel メタデータの期限切れの最終確認: 1:05:02 時間前の 2020年01月05日 09時42分38秒 に実施しました。 利用可能なパッケージ 名前 : mariadb エポック : 3 バージョン : 10.3.11 リリース : 2.module_el8.0.0+35+6f2527ed アーキテクチ : x86_64 サイズ : 6.2 M ソース : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm Repo : AppStream 概要 : A very fast and robust SQL database server URL : http://mariadb.org ライセンス : GPLv2 with exceptions and LGPLv2 and BSD. 説明 : MariaDB is a community developed branch of MySQL - a multi-user, : multi-threaded SQL database server. It is a client/server : implementation consisting of a server daemon (mysqld) and many : different client programs and libraries. The base package : contains the standard MariaDB/MySQL client programs and generic : MySQL files. 名前 : mariadb-devel エポック : 3 バージョン : 10.3.11 リリース : 2.module_el8.0.0+35+6f2527ed アーキテクチ : x86_64 サイズ : 1.0 M ソース : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm Repo : AppStream 概要 : Files for development of MariaDB/MySQL applications URL : http://mariadb.org ライセンス : GPLv2 with exceptions and LGPLv2 and BSD. 説明 : MariaDB is a multi-user, multi-threaded SQL database server. : MariaDB is a community developed branch of MySQL. : : : : : This package contains everything needed for developing : MariaDB/MySQL server applications. For developing client : applications, use mariadb-connector-c package. 名前 : mariadb-server エポック : 3 バージョン : 10.3.11 リリース : 2.module_el8.0.0+35+6f2527ed アーキテクチ : x86_64 サイズ : 16 M ソース : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm Repo : AppStream 概要 : The MariaDB server and related files URL : http://mariadb.org ライセンス : GPLv2 with exceptions and LGPLv2 and BSD. 説明 : MariaDB is a multi-user, multi-threaded SQL database server. It : is a client/server implementation consisting of a server daemon : (mysqld) and many different client programs and libraries. This : package contains the MariaDB server and some accompanying files : and directories. MariaDB is a community developed branch of : MySQL.
MariaDBのインストール
dnf install mariadb mariadb-server mariadb-devel
[root@SV-NEPTUNE ~]# dnf install mariadb mariadb-server mariadb-devel メタデータの期限切れの最終確認: 1:05:26 時間前の 2020年01月05日 09時42分38秒 に 実施しました。 依存関係が解決しました。 ================================================================================ パッケージ アーキテクチャー バージョン リポジトリ サイズ ================================================================================ Installing: mariadb x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 6.2 M mariadb-devel x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 1.0 M mariadb-server x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 16 M 依存関係をインストール中: mariadb-common x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 62 k mariadb-connector-c-devel x86_64 3.0.7-1.el8 AppStream 63 k mariadb-errmsg x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 232 k perl-DBD-MySQL x86_64 4.046-2.module_el8.0.0+72+668237d8 AppStream 156 k perl-DBI x86_64 1.641-2.module_el8.0.0+66+fe1eca09 AppStream 740 k keyutils-libs-devel x86_64 1.5.10-6.el8 BaseOS 48 k krb5-devel x86_64 1.16.1-22.el8 BaseOS 546 k libcom_err-devel x86_64 1.44.3-2.el8 BaseOS 37 k libkadm5 x86_64 1.16.1-22.el8 BaseOS 184 k libselinux-devel x86_64 2.8-6.el8 BaseOS 199 k libsepol-devel x86_64 2.8-2.el8 BaseOS 85 k libverto-devel x86_64 0.3.0-5.el8 BaseOS 18 k openssl-devel x86_64 1:1.1.1-8.el8 BaseOS 2.3 M pcre2-devel x86_64 10.32-1.el8 BaseOS 605 k pcre2-utf16 x86_64 10.32-1.el8 BaseOS 228 k pcre2-utf32 x86_64 10.32-1.el8 BaseOS 220 k perl-Math-BigInt noarch 1:1.9998.11-5.el8 BaseOS 195 k perl-Math-Complex noarch 1.59-416.el8 BaseOS 108 k psmisc x86_64 23.1-3.el8 BaseOS 151 k zlib-devel x86_64 1.2.11-10.el8 BaseOS 56 k 弱い依存関係をインストール中: mariadb-backup x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 6.2 M mariadb-gssapi-server x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 49 k mariadb-server-utils x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed AppStream 1.6 M Enabling module streams: mariadb 10.3 perl-DBD-MySQL 4.046 perl-DBI 1.641 トランザクションの概要 ================================================================================ インストール 26 パッケージ ダウンロードサイズの合計: 38 M インストール済みのサイズ: 178 M これでよろしいですか? [y/N]: y
パッケージのダウンロード中です: (1/26): mariadb-common-10.3.11-2.module_el8.0.0 12 kB/s | 62 kB 00:05 (2/26): mariadb-connector-c-devel-3.0.7-1.el8.x 1.6 MB/s | 63 kB 00:00 (3/26): mariadb-devel-10.3.11-2.module_el8.0.0+ 2.0 MB/s | 1.0 MB 00:00 (4/26): mariadb-errmsg-10.3.11-2.module_el8.0.0 1.5 MB/s | 232 kB 00:00 (5/26): mariadb-gssapi-server-10.3.11-2.module_ 786 kB/s | 49 kB 00:00 (6/26): mariadb-10.3.11-2.module_el8.0.0+35+6f2 964 kB/s | 6.2 MB 00:06 (7/26): mariadb-server-utils-10.3.11-2.module_e 4.3 MB/s | 1.6 MB 00:00 (8/26): perl-DBD-MySQL-4.046-2.module_el8.0.0+7 2.8 MB/s | 156 kB 00:00 (9/26): mariadb-backup-10.3.11-2.module_el8.0.0 895 kB/s | 6.2 MB 00:07 (10/26): perl-DBI-1.641-2.module_el8.0.0+66+fe1 4.8 MB/s | 740 kB 00:00 (11/26): keyutils-libs-devel-1.5.10-6.el8.x86_6 329 kB/s | 48 kB 00:00 (12/26): libcom_err-devel-1.44.3-2.el8.x86_64.r 1.9 MB/s | 37 kB 00:00 (13/26): libkadm5-1.16.1-22.el8.x86_64.rpm 2.1 MB/s | 184 kB 00:00 (14/26): krb5-devel-1.16.1-22.el8.x86_64.rpm 2.8 MB/s | 546 kB 00:00 (15/26): libsepol-devel-2.8-2.el8.x86_64.rpm 2.9 MB/s | 85 kB 00:00 (16/26): libselinux-devel-2.8-6.el8.x86_64.rpm 4.0 MB/s | 199 kB 00:00 (17/26): libverto-devel-0.3.0-5.el8.x86_64.rpm 970 kB/s | 18 kB 00:00 (18/26): pcre2-devel-10.32-1.el8.x86_64.rpm 3.6 MB/s | 605 kB 00:00 (19/26): pcre2-utf16-10.32-1.el8.x86_64.rpm 1.3 MB/s | 228 kB 00:00 (20/26): openssl-devel-1.1.1-8.el8.x86_64.rpm 6.1 MB/s | 2.3 MB 00:00 (21/26): pcre2-utf32-10.32-1.el8.x86_64.rpm 4.7 MB/s | 220 kB 00:00 (22/26): perl-Math-BigInt-1.9998.11-5.el8.noarc 4.3 MB/s | 195 kB 00:00 (23/26): perl-Math-Complex-1.59-416.el8.noarch. 3.0 MB/s | 108 kB 00:00 (24/26): zlib-devel-1.2.11-10.el8.x86_64.rpm 2.5 MB/s | 56 kB 00:00 (25/26): psmisc-23.1-3.el8.x86_64.rpm 4.1 MB/s | 151 kB 00:00 (26/26): mariadb-server-10.3.11-2.module_el8.0. 4.0 MB/s | 16 MB 00:04 -------------------------------------------------------------------------------- 合計 2.2 MB/s | 38 MB 00:16 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 Installing : mariadb-common-3:10.3.11-2.module_el8.0.0+35+6f252 1/26 Installing : mariadb-errmsg-3:10.3.11-2.module_el8.0.0+35+6f252 2/26 Installing : zlib-devel-1.2.11-10.el8.x86_64 3/26 Installing : psmisc-23.1-3.el8.x86_64 4/26 Installing : perl-Math-Complex-1.59-416.el8.noarch 5/26 Installing : perl-Math-BigInt-1:1.9998.11-5.el8.noarch 6/26 Installing : perl-DBI-1.641-2.module_el8.0.0+66+fe1eca09.x86_64 7/26 Installing : perl-DBD-MySQL-4.046-2.module_el8.0.0+72+668237d8. 8/26 Installing : mariadb-backup-3:10.3.11-2.module_el8.0.0+35+6f252 9/26 Installing : mariadb-gssapi-server-3:10.3.11-2.module_el8.0.0+3 10/26 Installing : mariadb-server-utils-3:10.3.11-2.module_el8.0.0+35 11/26 scriptletの実行中: mariadb-server-3:10.3.11-2.module_el8.0.0+35+6f252 12/26 Installing : mariadb-server-3:10.3.11-2.module_el8.0.0+35+6f252 12/26 scriptletの実行中: mariadb-server-3:10.3.11-2.module_el8.0.0+35+6f252 12/26 Installing : mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86 13/26 Installing : pcre2-utf32-10.32-1.el8.x86_64 14/26 Installing : pcre2-utf16-10.32-1.el8.x86_64 15/26 Installing : pcre2-devel-10.32-1.el8.x86_64 16/26 Installing : libverto-devel-0.3.0-5.el8.x86_64 17/26 Installing : libsepol-devel-2.8-2.el8.x86_64 18/26 Installing : libselinux-devel-2.8-6.el8.x86_64 19/26 Installing : libkadm5-1.16.1-22.el8.x86_64 20/26 Installing : libcom_err-devel-1.44.3-2.el8.x86_64 21/26 Installing : keyutils-libs-devel-1.5.10-6.el8.x86_64 22/26 Installing : krb5-devel-1.16.1-22.el8.x86_64 23/26 Installing : openssl-devel-1:1.1.1-8.el8.x86_64 24/26 Installing : mariadb-connector-c-devel-3.0.7-1.el8.x86_64 25/26 Installing : mariadb-devel-3:10.3.11-2.module_el8.0.0+35+6f2527 26/26 scriptletの実行中: mariadb-devel-3:10.3.11-2.module_el8.0.0+35+6f2527 26/26 検証 : mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86 1/26 検証 : mariadb-backup-3:10.3.11-2.module_el8.0.0+35+6f252 2/26 検証 : mariadb-common-3:10.3.11-2.module_el8.0.0+35+6f252 3/26 検証 : mariadb-connector-c-devel-3.0.7-1.el8.x86_64 4/26 検証 : mariadb-devel-3:10.3.11-2.module_el8.0.0+35+6f2527 5/26 検証 : mariadb-errmsg-3:10.3.11-2.module_el8.0.0+35+6f252 6/26 検証 : mariadb-gssapi-server-3:10.3.11-2.module_el8.0.0+3 7/26 検証 : mariadb-server-3:10.3.11-2.module_el8.0.0+35+6f252 8/26 検証 : mariadb-server-utils-3:10.3.11-2.module_el8.0.0+35 9/26 検証 : perl-DBD-MySQL-4.046-2.module_el8.0.0+72+668237d8. 10/26 検証 : perl-DBI-1.641-2.module_el8.0.0+66+fe1eca09.x86_64 11/26 検証 : keyutils-libs-devel-1.5.10-6.el8.x86_64 12/26 検証 : krb5-devel-1.16.1-22.el8.x86_64 13/26 検証 : libcom_err-devel-1.44.3-2.el8.x86_64 14/26 検証 : libkadm5-1.16.1-22.el8.x86_64 15/26 検証 : libselinux-devel-2.8-6.el8.x86_64 16/26 検証 : libsepol-devel-2.8-2.el8.x86_64 17/26 検証 : libverto-devel-0.3.0-5.el8.x86_64 18/26 検証 : openssl-devel-1:1.1.1-8.el8.x86_64 19/26 検証 : pcre2-devel-10.32-1.el8.x86_64 20/26 検証 : pcre2-utf16-10.32-1.el8.x86_64 21/26 検証 : pcre2-utf32-10.32-1.el8.x86_64 22/26 検証 : perl-Math-BigInt-1:1.9998.11-5.el8.noarch 23/26 検証 : perl-Math-Complex-1.59-416.el8.noarch 24/26 検証 : psmisc-23.1-3.el8.x86_64 25/26 検証 : zlib-devel-1.2.11-10.el8.x86_64 26/26 インストール済み: mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-devel-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-server-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-backup-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-gssapi-server-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-server-utils-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-common-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 mariadb-connector-c-devel-3.0.7-1.el8.x86_64 mariadb-errmsg-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 perl-DBD-MySQL-4.046-2.module_el8.0.0+72+668237d8.x86_64 perl-DBI-1.641-2.module_el8.0.0+66+fe1eca09.x86_64 keyutils-libs-devel-1.5.10-6.el8.x86_64 krb5-devel-1.16.1-22.el8.x86_64 libcom_err-devel-1.44.3-2.el8.x86_64 libkadm5-1.16.1-22.el8.x86_64 libselinux-devel-2.8-6.el8.x86_64 libsepol-devel-2.8-2.el8.x86_64 libverto-devel-0.3.0-5.el8.x86_64 openssl-devel-1:1.1.1-8.el8.x86_64 pcre2-devel-10.32-1.el8.x86_64 pcre2-utf16-10.32-1.el8.x86_64 pcre2-utf32-10.32-1.el8.x86_64 perl-Math-BigInt-1:1.9998.11-5.el8.noarch perl-Math-Complex-1.59-416.el8.noarch psmisc-23.1-3.el8.x86_64 zlib-devel-1.2.11-10.el8.x86_64 完了しました!
インストール後のパッケージ確認
dnf list installed | grep mariadb
[root@SV-NEPTUNE ~]# dnf list installed | grep mariadb mariadb.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-backup.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-common.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-connector-c.x86_64 3.0.7-1.el8 @AppStream mariadb-connector-c-config.noarch 3.0.7-1.el8 @AppStream mariadb-connector-c-devel.x86_64 3.0.7-1.el8 @AppStream mariadb-devel.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-errmsg.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-gssapi-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream mariadb-server-utils.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadbの起動とステータス確認
起動
systemctl start mariadb
[root@SV-NEPTUNE ~]# systemctl start mariadb
ステータス確認
systemctl status mariadb
[root@SV-NEPTUNE ~]# systemctl status mariadb ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr> Active: active (running) since Sun 2020-01-05 10:49:08 JST; 13s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 7825 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, st> Process: 7691 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service > Process: 7667 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, stat> Main PID: 7793 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 11141) Memory: 85.7M CGroup: /system.slice/mariadb.service mq7793 /usr/libexec/mysqld --basedir=/usr 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: Please report any probl> 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: The latest information > 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: You can find additional> 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: http://dev.mysql.com 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: Consider joining MariaD> 1月 05 10:49:08 SV-NEPTUNE mysql-prepare-db-dir[7691]: https://mariadb.org/get> 1月 05 10:49:08 SV-NEPTUNE mysqld[7793]: 2020-01-05 10:49:08 0 [Note] /usr/lib> 1月 05 10:49:08 SV-NEPTUNE mysqld[7793]: 2020-01-05 10:49:08 0 [Warning] Could> 1月 05 10:49:08 SV-NEPTUNE mysqld[7793]: 2020-01-05 10:49:08 0 [Warning] Chang> 1月 05 10:49:08 SV-NEPTUNE systemd[1]: Started MariaDB 10.3 database server.
ps -aux | grep mysqld
[root@SV-NEPTUNE ~]# ps -aux | grep mysqld mysql 7793 0.3 4.8 1300532 90780 ? Ssl 10:49 0:00 /usr/libexec/mysqld --basedir=/usr
自動起動の設定
systemctl enable mariadb
[root@SV-NEPTUNE ~]# systemctl enable 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.
systemctl is-enabled mariadb
[root@SV-NEPTUNE ~]# systemctl is-enabled mariadb enabled
MariaDBインストール後の基本設定の手順
インストールが終わったので、つづけてmariadbの基本設定を行います。
「mysql_secure_installation」の実行
「mysql_secure_installation」の実行で以下が行われます
- MariaDB管理者ユーザのパスワード設定
- 匿名ユーザーの削除
- 管理者のリモート接続は許可しない)
- テストDBの削除
- 設定を再読み込み
mysql_secure_installation
[root@SV-NEPTUNE ~]# 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): ★★[Enter]キ★★ OK, successfully used password, moving on...
DB管理者ユーザーのパスワード設定
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!
anonymous(匿名ユーザー)のRemove(削除)
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!
root login remotely(管理者のリモート接続)はDissallow(許可しない)
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!
test database(テストDB)のRemove(削除)
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... ... Success! - Removing privileges on test database... ... Success!
Reloading(設定を再読み込み)する
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!
文字コードの変更(「mariadb-server.cnf」ファイルの編集)
編集前のファイルのバックアップ
cd /etc/my.cnf.d cp -p /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.original_bk
[root@SV-NEPTUNE ~]# cd /etc/my.cnf.d [root@SV-NEPTUNE my.cnf.d]# ls auth_gssapi.cnf enable_encryption.preset mysql-clients.cnf client.cnf mariadb-server.cnf [root@SV-NEPTUNE my.cnf.d]# cp -p /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.original_bk [root@SV-NEPTUNE my.cnf.d]# ls -l 合計 24 -rw-r--r-- 1 root root 41 6月 24 2019 auth_gssapi.cnf -rw-r--r-- 1 root root 295 5月 14 2019 client.cnf -rw-r--r-- 1 root root 763 11月 17 2018 enable_encryption.preset -rw-r--r-- 1 root root 1458 6月 24 2019 mariadb-server.cnf -rw-r--r-- 1 root root 1458 6月 24 2019 mariadb-server.cnf.original_bk -rw-r--r-- 1 root root 232 11月 17 2018 mysql-clients.cnf
「mariadb-server.cnf」ファイルの編集
vi mariadb-server.cnf
[root@SV-NEPTUNE my.cnf.d]# vi mariadb-server.cnf
左が編集後、右が編集前
00046 |# This group is only read by MariaDB servers, not ||00046 |# This group is only read by MariaDB servers, not 00047 |# If you use the same .cnf file for MySQL and Mari||00047 |# If you use the same .cnf file for MySQL and Mari 00048 |# you can put MariaDB-only options here ||00048 |# you can put MariaDB-only options here 00049 |[mariadb] ||00049 |[mariadb] 00050 L|character-set-server = utf8mb4 || | 00051 L|[client-mariadb] || | 00052 L|default-character-set = utf8mb4 || |
設定変更後のMariaDBの再起動とステータス確認
systemctl restart mariadb
[root@SV-NEPTUNE my.cnf.d]# systemctl restart mariadb
systemctl status mariadb
[root@SV-NEPTUNE my.cnf.d]# systemctl status mariadb ● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pre> Active: active (running) since Sun 2020-01-05 10:59:16 JST; 7s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 8038 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, st> Process: 7968 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service > Process: 7944 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, stat> Main PID: 8006 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 11141) Memory: 66.9M CGroup: /system.slice/mariadb.service mq8006 /usr/libexec/mysqld --basedir=/usr 1月 05 10:59:16 SV-NEPTUNE systemd[1]: Stopped MariaDB 10.3 database server. 1月 05 10:59:16 SV-NEPTUNE systemd[1]: Starting MariaDB 10.3 database server... 1月 05 10:59:16 SV-NEPTUNE mysql-prepare-db-dir[7968]: Database MariaDB is pro> 1月 05 10:59:16 SV-NEPTUNE mysql-prepare-db-dir[7968]: If this is not the case> 1月 05 10:59:16 SV-NEPTUNE mysqld[8006]: 2020-01-05 10:59:16 0 [Note] /usr/lib> 1月 05 10:59:16 SV-NEPTUNE mysqld[8006]: 2020-01-05 10:59:16 0 [Warning] Could> 1月 05 10:59:16 SV-NEPTUNE mysqld[8006]: 2020-01-05 10:59:16 0 [Warning] Chang> 1月 05 10:59:16 SV-NEPTUNE systemd[1]: Started MariaDB 10.3 database server.
テスト用DBを作成して動作確認
DBに接続
mysql -uroot -p●●●●(さきほど設定したDB管理者パスワード)
[root@SV-NEPTUNE my.cnf.d]# mysql -uroot -p●●●● Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.3.11-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. MariaDB [(none)]>
テストDBの作成
create database test_db;
MariaDB [(none)]> create database test_db; Query OK, 1 row affected (0.000 sec)
DB一覧の表示
show databases;
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test_db | +--------------------+ 4 rows in set (0.000 sec)
テストDBに接続
use test_db;
MariaDB [(none)]> use test_db; Database changed MariaDB [test_db]>
DBの文字コード表示
show variables like "chara%";
MariaDB [test_db]> show variables like "chara%"; +--------------------------+------------------------------+ | Variable_name | Value | +--------------------------+------------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mariadb/charsets/ | +--------------------------+------------------------------+ 8 rows in set (0.001 sec)
確認が終わったら、テストDBは削除
drop database test_db;
MariaDB [test_db]> drop database test_db; Query OK, 0 rows affected (0.001 sec)
再度、DBの一覧を表示
show databases;
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.000 sec)
終了
quit
MariaDB [(none)]> quit Bye [root@SV-NEPTUNE my.cnf.d]#
参考にしたサイト
www.rem-system.comインフラエンジニアになるための勉強のやり方
私は、某SIerに勤務しながら、WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。現在の会社で直接担当している業務の中では、決まった技術しか触れないけれど、
「他にも将来役に立ちそうなインフラ技術を勉強したい」「働きながらでもできる効率的なインフラエンジニアの勉強方法を知りたい」と考えている方のために、
①おすすめの書籍と、②おススメのオンライン学習サイト、③おすすめのエンジニアスクールを紹介します。
働きながら勉強するための、おススメの書籍と、オンラインで学習できるサイトの紹介です。
インフラエンジニアの勉強ができるおススメ書籍
朝の通勤時や帰宅時の電車の中や、社外打合せへの**移動中などに勉強するなら、やはり書籍が一番**だと思います。インフラエンジニアの教科書
LINE社に創業時から在籍しているインフラエンジニア・プロマネの「佐野裕」さんの本です。twitter.com
膨大なトラフィックをさばくLINE社にて構築・保守を行っている現役エンジニアが記すITインフラの必須知識と経験の数々!
サーバ、OS、ネットワーク機器、データセンター、購買と商談、障害対応、大規模インフラ、成長するために必要なスキルなど、基礎知識から実践まで言及。
ITインフラの世界が理解できる珠玉の1冊!
インフラエンジニアの教科書 (C&R研究所) 佐野裕 |
1週間でLPICの基礎が学べる本
Linuxの資格「LPIC」の試験対策を初心者向けに書いた入門書です。Linuxの資格として広く知られているLPICですが、あまり知識の無いまま試験対策を始める人も多いのではないでしょうか。しかし、試験対策書は試験範囲についてのみ解説しているものが多く、初心者が理解するのは困難です。本書は、初心者がスムーズに試験対策を行えるよう、事前に基礎固めを行うLinux入門書です。試験情報や模擬問題も掲載しているので、資格取得を視野に入れた効率的な基礎学習が行えます。
1週間でLPICの基礎が学べる本 第3版 徹底攻略シリーズ (インプレス) 中島能和 |
インフラエンジニアの勉強ができるオンライン学習サイト
Udemy (オンライン動画学習サイト)
Udemy(ユーデミー)は、オンラインで動画で学習できるサービスです。ITエンジニア系の講座もたくさん公開されています。
Udemyの特徴
- ユーザー登録すれば、第1回の講座は無料で視聴できる
- 無料のコンテンツもある
- 過去に受講した人の人数や、受講した人の評価も表示されるので選びやすい
インフラエンジニアの勉強ができる専門スクール
リナックスアカデミー(ITエンジニア専門スクール)
スクールというと、昼間働いている人には難しいかもしれませんが、以下に紹介するスクールには、
Linuxサーバとネットワークとを両分野ともに学べるコースが、
夜間・土日での5か月~7か月の期間で用意されています。
リナックスアカデミー(ITエンジニア専門スクール) http://www.linuxacademy.ne.jp
リナックスアカデミーの特徴
- 初心者でも最短4週間でエンジニアになれる「IT教育専門機関」
- 100%ライブ抗議の「少人数クラス担任制」
- 実務スキルを身につける「PBL(Project Based Learning)」が充実
- 圧倒的な合格実績と「合格保証制度」
- 就職実績と「就職・転職サポート」が充実
リナックスアカデミーが選ばれ続ける最大の理由、それはIT技術に特化した日本初のIT教育専門機関だからということです。他を寄せ付けないカリキュラムと講師の質で日本No.1のオープンソース専門スクールだと認知されています。
スクールとしては世界で初めてLPI(Linux技術者認定機関)プラチナスポンサーに加盟し、LPI-Jアカデミック認定校第一号スクール、OSS-DBアカデミック認定校第一号スクール、PostgreSQL CE認定校、国内唯一のPHP技術者育成認定校Zend Authorized Training Center など、数々の認定を受けています。 先日来日したLPIC資格試験の開発責任者であるMatthew Rice氏にも、「世界でNo.1と言われる日本の市場で、リナックスアカデミーはNo.1のスクールだと言われている。それは素晴らしいことだ」という言葉を頂いています。
リナックスアカデミー(ITエンジニア専門スクール)の資料請求(無料)について詳しく見てみる
以上、読んでいただきありがとうございました。