GNU/Linux >> Linux の 問題 >  >> Fedora

Fedora35にMariadbをインストールして設定する方法

MariaDBは、OracleによるMySQLの買収に対応して、2009年にMySQLのソフトウェアフォークとして開発されました。 MariaDBは、GNU GeneralPublicLicenseの下で無料のオープンソースソフトウェアを維持する予定です。これはほとんどのクラウド製品の一部であり、ほとんどのLinuxディストリビューションのデフォルトです。

このガイドでは、Fedora35サーバー/ワークステーションにMariaDBをインストールして構成する方法を学習します。

関連記事

  • Debian11にMariadb10をインストールして設定する方法
  • Ubuntu20.04にMariadb10をインストールして構成する方法
  • Fedora34/35にMysqlServer8をインストールして設定する方法
  • Mysql8をRockyLinux/Centos8にインストールする方法
  • Ubuntu20.04にmysql8をインストールしてセットアップする方法

前提条件

フォローするには、次のことを確認してください。

  • 最新のFedoraサーバー/ワークステーション
  • サーバーまたはSudoアクセス権を持つユーザーへのrootアクセス
  • サーバーからインターネットへのアクセス

目次

  1. システムの更新
  2. Mariadbのインストール
  3. Mariadbの構成
  4. MariaDBのテスト

1。システムを更新する

先に進む前に、Fedoraサーバーが最新であることを確認しましょう。

ターミナルで、これらを入力します。 -y dnf updateのオプション アップグレードを受け入れるためにシステムが一時停止しないようにすることです。

sudo dnf -y update

2。 mariadbのインストール

Mariadbは、Fedoraのデフォルトのリポジトリにあります。このコマンドを使用して、データベースサーバーをインストールします。次のコマンドで検索して確認できます:

sudo dnf search mariadb-server

このコマンドを使用してMariadbをインストールします

sudo dnf install -y mariadb-server

Mariadbの起動と有効化

Mariadbはデフォルトでは起動されません。次のコマンドを使用して開始します:

sudo systemctl start mariadb

ステータスを確認して、サービスが稼働中であることを確認します

$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2021-11-13 05:46:38 UTC; 18s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 9385 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
    Process: 9408 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
    Process: 9504 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
   Main PID: 9490 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 13 (limit: 4585)
     Memory: 82.2M
        CPU: 460ms
     CGroup: /system.slice/mariadb.service
             └─9490 /usr/libexec/mariadbd --basedir=/usr

Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: See the MariaDB Knowledgebase at https://mariadb.com/kb or the
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: MySQL manual for more instructions.
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: Please report any problems at https://mariadb.org/jira
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: The latest information about MariaDB is available at https://mariadb.org/.
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: You can find additional information about the MySQL part at:
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: https://dev.mysql.com
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: Consider joining MariaDB's strong and vibrant community:
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: https://mariadb.org/get-involved/
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadbd[9490]: 2021-11-13  5:46:37 0 [Note] /usr/libexec/mariadbd (mysqld 10.5.12-MariaDB) starting as process 9490 ...
Nov 13 05:46:38 ip-10-2-40-174.us-west-2.compute.internal systemd[1]: Started MariaDB 10.5 database server.

起動したので、次のコマンドを使用して起動時に起動を有効にします。

$ 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.

3。 MariaDBの構成

新しいMariaDBインストールの場合、次のステップは、含まれているセキュリティスクリプトを実行することです。このスクリプトは、安全性の低いデフォルトオプションの一部を変更します。これを使用して、リモートのルートをブロックします ログインして、未使用のデータベースユーザーを削除します。

セキュリティスクリプトを実行します:

sudo mysql_secure_installation

これにより、MariaDBインストールのセキュリティオプションにいくつかの変更を加えることができる一連のプロンプトが表示されます。最初のプロンプトでは、現在のデータベースのルートを入力するように求められます パスワード。まだ設定していないので、ENTERを押します 「なし」を示します。

次のプロンプトでは、データベースのルートを設定するかどうかを尋ねられます パスワード。 Nと入力します 次に、ENTERを押します 。 Fedoraでは、ルート MariaDBのアカウントは自動システムメンテナンスと密接に関連しているため、そのアカウントに構成されている認証方法を変更しないでください。そうすることで、管理者アカウントへのアクセスを削除することにより、パッケージの更新によってデータベースシステムが破壊される可能性があります。後で、ソケット認証がユースケースに適していない場合に、パスワードアクセス用に追加の管理者アカウントをオプションで設定する方法について説明します。

そこから、Yを押すことができます 次に、ENTER 後続のすべての質問のデフォルトを受け入れます。これにより、一部の匿名ユーザーとテストデータベースが削除され、リモートのルートが無効になります。 ログインし、これらの新しいルールをロードして、MariaDBが行った変更をすぐに尊重するようにします。

これは私のサーバーの出力です

$ 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] n
 ... skipping.

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

Change the root password? [Y/n]
New password:
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.

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!

5。 MariaDBのテスト

mariadbがすべてセットアップされて実行されているので、接続を受け入れることができることを確認する必要があります。

テストするには、rootユーザーでmariadbに接続します– mysql -h 127.0.0.1 -u root -p

出力:

$ mysql -h 127.0.0.1 -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.12-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)]>

mariadbのバージョンを確認してください:

MariaDB [(none)]> SELECT VERSION();
+-----------------+
| VERSION()       |
+-----------------+
| 10.5.12-MariaDB |
+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]>

追加のチェックについては、mysqladminを使用してデータベースに接続してみてください。 ツール。管理コマンドを実行できるクライアントです。たとえば、このコマンドは、 rootとしてMariaDBに接続するように指示します。 Unixソケットを使用してバージョンを返します:

sudo mysqladmin version

次のような出力が表示されます:

$ sudo mysqladmin version
mysqladmin  Ver 9.1 Distrib 10.5.12-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version		10.5.12-MariaDB
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			5 min 38 sec

Threads: 1  Questions: 21  Slow queries: 0  Opens: 20  Open tables: 13  Queries per second avg: 0.062

これは、MariaDBが稼働中であり、ユーザーが正常に認証できることを意味します。

結論

このガイドでは、SQLサーバーとして機能するようにMariaDBをインストールしました。インストールプロセス中に、サーバーも保護しました。


Fedora
  1. MysqlServer8をFedora34/35にインストールして構成する方法

  2. Fedora34にRedis6をインストールして設定する方法

  3. Debian11にMariadb10をインストールして設定する方法

  1. Fedora34にPostgres14をインストールして設定する方法

  2. Fedora35にAnsibleをインストールして設定する方法

  3. Python2とPython3をFedora35にインストールする方法

  1. MariaDBと一緒にFedora31にOpenLiteSpeedサーバーをインストールして構成する方法

  2. Ubuntu20.04にMariadb10をインストールして構成する方法

  3. OpenSUSELeap15.3にMariadb10をインストールして構成する方法