LoginSignup
0
0

More than 1 year has passed since last update.

CentOS8へMariaDB10.4をインストールする方法

Last updated at Posted at 2020-11-13

2021.06.07 追記

なんか直りました。
ただし、 --disablerepo=AppStream--disablerepo=appstream になりました。

2021.06.06 追記

なんかインストールできなくなってます。


毎回ググるのがめんどくさいので、備忘録として記事にします

システムの更新

サーバー上で実行されている重要なサービスがない場合は、システムの更新をしてから。

sudo dnf -y upgrade

CentOS8にMariaDBのリポジトリを追加

x86_64 CPUマシンのリポジトリの追加のコマンドは以下。

sudo tee /etc/yum.repos.d/MariaDB.repo<<EOF 
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

ちなみにRHEL8の場合は以下のコマンド。

sudo tee /etc/yum.repos.d/MariaDB.repo<<EOF 
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/rhel8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

インストールする

コマンドは以下。

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=appstream 
sudo systemctl enable --now mariadb

ちなみにRHEL8の場合は以下。

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=rhel-8-for-x86_64-appstream-rpms 
sudo systemctl enable --now mariadb

セキュリティで保護する

下記のコマンドで初期設定するみたい。

sudo mysql_secure_installation

ちなみに参考にしたサイトと手元の環境でメッセージが違ったので、ログを貼っておきます。

[root@localhost vagrant]# sudo 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 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'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


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

Change the root password? [Y/n] n
 ... skipping.

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...
 ... 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
 ... 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@localhost vagrant]# mysql --version
mysql  Ver 15.1 Distrib 10.4.17-MariaDB, for Linux (x86_64) using readline 5.1

追記

Vagrant + VirtualBox の環境で試したのですが、 dnf upgrade のせいでマウントができなくなってしまいました。
検索してみたら、以下のようなコマンドをするように書いてありましたが、いずれもダメでした。
なお、環境は下記です。
VirtualBox バージョン 6.1.16 r140961 (Qt5.6.2)
Vagrant 2.2.13
CentOS Linux release 8.2.2004 (Core)

Vagrantのプラグインを入れる
vagrant plugin install vagrant-vbguest
# 普通にダメだった
vagrant up {vagrant global-status で調べたID}
# これも見かけたので試してみた
vagrant vbguest {vagrant global-status で調べたID}
# 再起動してもダメだった
vagrant reload {vagrant global-status で調べたID}
プラグインの再インストール
vagrant plugin expunge --reinstall
# これで起動してもダメだった
vagrant up {vagrant global-status で調べたID}
# CentOS上でもう一度更新してみる
dnf update
# この後で再起動してみたけどダメだった
vagrant reload {vagrant global-status で調べたID}

さらに追記

いろいろ試した結果、最終的に以下を実施したら直りました。よかったよかった。

# プラグインのインストール
vagrant plugin install vagrant-vbguest
# とりあえず再起動(この段階では直っていない)
vagrant reload {vagrant global-status で調べたID}
# ssh接続
vagrant ssh {vagrant global-status で調べたID}
# kernel周りのやつとかインストールする
dnf install epel-release
dnf install kernel-devel kernel-headers gcc perl make dkms
# sshを抜けてからもう一度再起動
vagrant reload {vagrant global-status で調べたID}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0