Fedora 35にMariaDB をインストールする

2021年12月14日

環境情報
# cat /etc/redhat-release
Fedora release 35 (Thirty Five)

インストールの方法
1.システムパッケージを更新します
# sudo dnf upgrade
# sudo dnf update

2.MariaDBをインストールします
# sudo dnf install mariadb-server

3.MariaDBを起動します
# sudo systemctl start mariadb

自動起動を設定します

# sudo 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.

ステータスを確認します

# sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2021-12-14 18:23:39 JST; 2min 30s ago

4. MariaDBの初期化を行います

# 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’.
# Unix_Socket 認証に切り替えるか否か
Switch to unix_socket authentication [Y/n] n #nを入力
… skipping.

You already have your root account protected, so you can safely answer 'n’.
# MariaDB root パスワードを設定するか否か
Change the root password? [Y/n] 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 #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 のリモートログインは無効
Disallow root login remotely? [Y/n] y #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 #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!

5.MariaDB に root ユーザーで接続します

# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.5-10.5.13-MariaDB MariaDB Server

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

6.MariaDBバージョンを確認します

mysql> SELECT VERSION();
+-----------------+
| VERSION()       |
+-----------------+
| 10.5.13-MariaDB |
+-----------------+
1 row in set (0.00 sec)

7.ファイアウォールを設定します

# sudo firewall-cmd --add-service=mysql
success
# sudo firewall-cmd --runtime-to-permanent
success

 

Fedora 35

Posted by arkgame