conohaVPS(CentOS Stream9)にMariaDBをインストール

MySQL(MariaDB)
この記事が対象とする環境
CentOS Stream 9
MariaDB 10.5

現状確認

管理者ユーザーに切り替える

管理者ユーザーでログインしていない場合に切り替えます。パスワードの入力を求められるので、rootユーザーのパスワードを入力します。

su
Password: 

利用可能なMariaDBのバージョンを確認する

インストールしたいバージョンか確認する。

dnf list maria*
Last metadata expiration check: 0:25:38 ago on Thu 25 May 2023 06:49:04 AM JST.
Available Packages
mariadb.x86_64                        3:10.5.16-2.el9    appstream
mariadb-backup.x86_64                 3:10.5.16-2.el9    appstream
mariadb-common.x86_64                 3:10.5.16-2.el9    appstream
mariadb-connector-c.i686              3.2.6-1.el9        appstream
mariadb-connector-c.x86_64            3.2.6-1.el9        appstream
mariadb-connector-c-config.noarch     3.2.6-1.el9        appstream
mariadb-connector-c-devel.i686        3.2.6-1.el9        appstream
mariadb-connector-c-devel.x86_64      3.2.6-1.el9        appstream
mariadb-connector-odbc.x86_64         3.1.12-3.el9       appstream
mariadb-embedded.x86_64               3:10.5.16-2.el9    appstream
mariadb-errmsg.x86_64                 3:10.5.16-2.el9    appstream
mariadb-gssapi-server.x86_64          3:10.5.16-2.el9    appstream
mariadb-java-client.noarch            3.0.3-1.el9        appstream
mariadb-oqgraph-engine.x86_64         3:10.5.16-2.el9    appstream
mariadb-pam.x86_64                    3:10.5.16-2.el9    appstream
mariadb-server.x86_64                 3:10.5.16-2.el9    appstream
mariadb-server-galera.x86_64          3:10.5.16-2.el9    appstream
mariadb-server-utils.x86_64           3:10.5.16-2.el9    appstream

詳細情報の確認はこちら。

dnf info mariadb-server
Last metadata expiration check: 0:35:54 ago on Thu 25 May 2023 06:49:04 AM JST.
Available Packages
Name         : mariadb-server
Epoch        : 3
Version      : 10.5.16
Release      : 2.el9
Architecture : x86_64
Size         : 9.4 M
Source       : mariadb-10.5.16-2.el9.src.rpm
Repository   : appstream
Summary      : The MariaDB server and related files
URL          : http://mariadb.org
License      : GPLv2 and LGPLv2
Description  : MariaDB is a multi-user, multi-threaded SQL database server. It is a
             : client/server implementation consisting of a server daemon (mariadbd)
             : and many different client programs and libraries. This package contains
             : the MariaDB server and some accompanying files and directories.
             : MariaDB is a community developed fork from MySQL.

MariaDBインストール

MariaDBインストール

「-y」を付けて依存関係も含めてインストールします。

dnf install -y mariadb-server
Last metadata expiration check: 0:36:44 ago on Thu 25 May 2023 06:49:04 AM JST.
Dependencies resolved.
==================================================================================
 Package                       Architecture  Version           Repository    Size
==================================================================================
Installing:
 mariadb-server                x86_64        3:10.5.16-2.el9   appstream    9.4 M
Installing dependencies:
 mariadb                       x86_64        3:10.5.16-2.el9   appstream    1.6 M
 mariadb-common                x86_64        3:10.5.16-2.el9   appstream     35 k
 mariadb-connector-c           x86_64        3.2.6-1.el9       appstream    198 k
 mariadb-connector-c-config    noarch        3.2.6-1.el9       appstream     11 k
 mariadb-errmsg                x86_64        3:10.5.16-2.el9   appstream    223 k
 mysql-selinux                 noarch        1.0.5-1.el9       appstream     36 k
 perl-AutoLoader               noarch        5.74-480.el9
(~ 略 ~)
 perl-NDBM_File                x86_64        1.15-480.el9      appstream     23 k
Transaction Summary
==================================================================================
Install  75 Packages

Total download size: 26 M
Installed size: 136 M
Downloading Packages:
(1/75): mariadb-common-10.5.16-2.el9.x86_64.rpm            930 kB/s |  35 kB     00:00
(2/75): mariadb-connector-c-3.2.6-1.el9.x86_64.rpm         5.2 MB/s | 198 kB     00:00
(3/75): mariadb-connector-c-config-3.2.6-1.el9.noarch.rpm  822 kB/s |  11 kB     00:00
(4/75): mariadb-errmsg-10.5.16-2.el9.x86_64.rpm            9.6 MB/s | 223 kB     00:00
(5/75): mariadb-gssapi-server-10.5.16-2.el9.x86_64.rpm     1.6 MB/s |  20 kB     00:00
(6/75): mariadb-10.5.16-2.el9.x86_64.rpm                   9.1 MB/s | 1.6 MB     00:00
(7/75): mariadb-server-utils-10.5.16-2.el9.x86_64.rpm      7.6 MB/s | 218 kB     00:00
(8/75): mysql-selinux-1.0.5-1.el9.noarch.rpm               1.2 MB/s |  36 kB     00:00
(9/75): perl-AutoLoader-5.74-480.el9.noarch.rpm            674 kB/s |  22 kB     00:00
(~ 略 ~)
(75/75): perl-libs-5.32.1-480.el9.x86_64.rpm                12 MB/s | 2.2 MB     00:00
--------------------------------------------------------------------------------------
Total                                                       18 MB/s |  26 MB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                               1/1 
  Installing       : mariadb-connector-c-config-3.2.6-1.el9.noarch                1/75 
  Installing       : mariadb-common-3:10.5.16-2.el9.x86_64                        2/75 
  Installing       : mariadb-connector-c-3.2.6-1.el9.x86_64                       3/75 
  Installing       : mariadb-errmsg-3:10.5.16-2.el9.x86_64                        4/75 
  Installing       : perl-Digest-1.19-4.el9.noarch                                5/75 
  Installing       : perl-Digest-MD5-2.58-4.el9.x86_64                            6/75 
  Installing       : perl-B-1.80-480.el9.x86_64                                   7/75 
  Installing       : perl-FileHandle-2.03-480.el9.noarch                          8/75 
  Installing       : perl-Data-Dumper-2.174-462.el9.x86_64                        9/75 
  Installing       : perl-libnet-3.13-4.el9.noarch                               10/75 
  Installing       : perl-AutoLoader-5.74-480.el9.noarch                         11/75 
(~ 略 ~)
  Running scriptlet: mariadb-3:10.5.16-2.el9.x86_64                              75/75 
  
  Verifying        : mariadb-3:10.5.16-2.el9.x86_64                               1/75 
  Verifying        : mariadb-backup-3:10.5.16-2.el9.x86_64                        2/75 
  Verifying        : mariadb-common-3:10.5.16-2.el9.x86_64                        3/75 
  Verifying        : mariadb-connector-c-3.2.6-1.el9.x86_64                       4/75 
  Verifying        : mariadb-connector-c-config-3.2.6-1.el9.noarch                5/75 
  Verifying        : mariadb-errmsg-3:10.5.16-2.el9.x86_64                        6/75 
  Verifying        : mariadb-gssapi-server-3:10.5.16-2.el9.x86_64                 7/75 
  Verifying        : mariadb-server-3:10.5.16-2.el9.x86_64                        8/75 
  Verifying        : mariadb-server-utils-3:10.5.16-2.el9.x86_64                  9/75 
  Verifying        : mysql-selinux-1.0.5-1.el9.noarch                            10/75 
  Verifying        : perl-AutoLoader-5.74-480.el9.noarch                         11/75 
(~ 略 ~)
  Verifying        : policycoreutils-python-utils-3.5-1.el9.noarch               75/75 
Installed products updated.

Installed:
  mariadb-3:10.5.16-2.el9.x86_64               mariadb-backup-3:10.5.16-2.el9.x86_64          mariadb-common-3:10.5.16-2.el9.x86_64        
  mariadb-connector-c-3.2.6-1.el9.x86_64       mariadb-connector-c-config-3.2.6-1.el9.noarch  mariadb-errmsg-3:10.5.16-2.el9.x86_64        
  mariadb-gssapi-server-3:10.5.16-2.el9.x86_64 mariadb-server-3:10.5.16-2.el9.x86_64          mariadb-server-utils-3:10.5.16-2.el9.x86_64  
  mysql-selinux-1.0.5-1.el9.noarch             perl-AutoLoader-5.74-480.el9.noarch            perl-B-1.80-480.el9.x86_64                   
  perl-Carp-1.50-460.el9.noarch                perl-Class-Struct-0.66-480.el9.noarch          perl-DBD-MariaDB-1.21-16.el9.x86_64          
  perl-DBI-1.643-9.el9.x86_64                  perl-Data-Dumper-2.174-462.el9.x86_64          perl-Digest-1.19-4.el9.noarch                
  perl-Digest-MD5-2.58-4.el9.x86_64            perl-DynaLoader-1.47-480.el9.x86_64            perl-Encode-4:3.08-462.el9.x86_64            
  perl-Errno-1.30-480.el9.x86_64               perl-Exporter-5.74-461.el9.noarch              perl-Fcntl-1.13-480.el9.x86_64               
  perl-File-Basename-2.85-480.el9.noarch       perl-File-Copy-2.34-480.el9.noarch             perl-File-Path-2.18-4.el9.noarch             
  perl-File-Temp-1:0.231.100-4.el9.noarch      perl-File-stat-1.09-480.el9.noarch             perl-FileHandle-2.03-480.el9.noarch          
  perl-Getopt-Long-1:2.52-4.el9.noarch         perl-Getopt-Std-1.12-480.el9.noarch            perl-HTTP-Tiny-0.076-460.el9.noarch          
  perl-IO-1.43-480.el9.x86_64                  perl-IO-Socket-IP-0.41-5.el9.noarch            perl-IO-Socket-SSL-2.073-1.el9.noarch        
  perl-IPC-Open3-1.21-480.el9.noarch           perl-MIME-Base64-3.16-4.el9.x86_64             perl-Math-BigInt-1:1.9998.18-460.el9.noarch  
  perl-Math-Complex-1.59-480.el9.noarch        perl-Mozilla-CA-20200520-6.el9.noarch          perl-NDBM_File-1.15-480.el9.x86_64           
  perl-Net-SSLeay-1.92-2.el9.x86_64            perl-POSIX-1.94-480.el9.x86_64                 perl-PathTools-3.78-461.el9.x86_64           
  perl-Pod-Escapes-1:1.07-460.el9.noarch       perl-Pod-Perldoc-3.28.01-461.el9.noarch        perl-Pod-Simple-1:3.42-4.el9.noarch          
  perl-Pod-Usage-4:2.01-4.el9.noarch           perl-Scalar-List-Utils-4:1.56-461.el9.x86_64   perl-SelectSaver-1.02-480.el9.noarch         
  perl-Socket-4:2.031-4.el9.x86_64             perl-Storable-1:3.21-460.el9.x86_64            perl-Symbol-1.08-480.el9.noarch              
  perl-Sys-Hostname-1.23-480.el9.x86_64        perl-Term-ANSIColor-5.01-461.el9.noarch        perl-Term-Cap-1.17-460.el9.noarch            
  perl-Text-ParseWords-3.30-460.el9.noarch     perl-Text-Tabs+Wrap-2013.0523-460.el9.noarch   perl-Time-Local-2:1.300-7.el9.noarch         
  perl-URI-5.09-3.el9.noarch                   perl-base-2.27-480.el9.noarch                  perl-constant-1.33-461.el9.noarch            
  perl-if-0.60.800-480.el9.noarch              perl-interpreter-4:5.32.1-480.el9.x86_64       perl-libnet-3.13-4.el9.noarch                
  perl-libs-4:5.32.1-480.el9.x86_64            perl-mro-1.23-480.el9.x86_64                   perl-overload-1.31-480.el9.noarch            
  perl-overloading-0.02-480.el9.noarch         perl-parent-1:0.238-460.el9.noarch             perl-podlators-1:4.14-460.el9.noarch         
  perl-subs-1.03-480.el9.noarch                perl-vars-1.05-480.el9.noarch                  policycoreutils-python-utils-3.5-1.el9.noarch

Complete!

MariaDBインストール後の確認

dnf list installed | grep mariadb
mariadb.x86_64                     3:10.5.16-2.el9  @appstream
mariadb-backup.x86_64              3:10.5.16-2.el9  @appstream
mariadb-common.x86_64              3:10.5.16-2.el9  @appstream
mariadb-connector-c.x86_64         3.2.6-1.el9      @appstream
mariadb-connector-c-config.noarch  3.2.6-1.el9      @appstream
mariadb-errmsg.x86_64              3:10.5.16-2.el9  @appstream
mariadb-gssapi-server.x86_64       3:10.5.16-2.el9  @appstream
mariadb-server.x86_64              3:10.5.16-2.el9  @appstream
mariadb-server-utils.x86_64        3:10.5.16-2.el9  @appstream

MariaDB起動の自動化

OS再起動時にMariaDBが自動的に起動するように設定します。

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.

MariaDBの起動状態を確認①

Active: inactive (dead)
起動の自動化はしましたが、起動操作をしていないし、OS再起動もしていないので、当然起動していません。

systemctl status mariadb
○ mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/

MariaDB起動

systemctl start mariadb

MariaDBの起動状態を確認②

MariaDBが起動しました。

systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; preset: disabled)
     Active: active (running) since Thu 2023-05-25 07:32:52 JST; 3s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 28299 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
    Process: 28321 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
    Process: 28423 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
   Main PID: 28407 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 15 (limit: 11125)
     Memory: 78.6M
        CPU: 680ms
     CGroup: /system.slice/mariadb.service
             └─28407 /usr/libexec/mariadbd --basedir=/usr

札幌在住エンジニア。JavaやPHPやWordPressを中心とした記事が中心です。

【SE歴】四半世紀以上
【Backend】php / java(spring) / c# / AdobeFlex / c++ / VB / cobol
【Frontend】 vue.js / jquery他 / javascript / html / css
【DB】oracle / mysql / mariadb / sqlite
【infrastructure】aws / oracle / gcp
【license】aws(saa-c03) / oracle master / XML Master / Sun Certified Programmer for the Java 2 Platform 1.4

Nobelをフォローする
MySQL(MariaDB)
Nobelをフォローする

コメント

タイトルとURLをコピーしました