LoginSignup
0
0

More than 1 year has passed since last update.

[MariaDB] Ubuntu 18.04 LTS に MariaDB 10.4 をインストールする方法

Last updated at Posted at 2021-11-16
Ubunt 18.04 LTSにMariaDB 10.4をインストールする。

はじめに

職場での環境構築において、MariaDB 10.4をインストールする際に沼ったので今後インストールを再度行う自分のために手順を記す。
ググってでてきた記事を参考にインストールを進めるもエラーが生じ原因が分からず解決できなかったため、Ubuntuを再インストールした段階からスタートした。最終的にUbuntu 18.04 LTS に MariaDB 10.4 をインストールを参照しながら進めたところうまくいった。

開発環境

Ubuntu 18.04 LTS, WSL 1

方法

まず、MariaDBパッケージリポジトリへのアクセスを構成する

$ curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
[info] Checking for script prerequisites.
[info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list
[info] Adding trusted package signing keys...
[info] Running apt-get update...
[info] Done adding trusted package signing keys

次に、以下のファイルが生成されるため、確認する。

/etc/apt/sources.list.d/mariadb.list
# MariaDB Server
# To use a different major version of the server, or to pin to a specific minor version, change URI below.
deb [arch=amd64,arm64] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/ubuntu bionic main

deb [arch=amd64,arm64 lang=none target-=CNF] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/ubuntu bionic main/debug

# MariaDB MaxScale
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
deb [arch=amd64] https://dlm.mariadb.com/repo/maxscale/latest/apt bionic main

# MariaDB Tools
deb [arch=amd64] http://downloads.mariadb.com/Tools/ubuntu bionic main

mariadb-serverのバージョンが10.6となっている。今回MariaDB 10.4をインストールしたいためバージョンを10.4に変更する。このとき書き込み権限がrootにしかないため権限を変更して編集する。

$ sudo chmod 766 mariadb.list
mariadb.list
$ vi mariadb.list
$ cat mariadb.list
# MariaDB Server
# To use a different major version of the server, or to pin to a specific minor version, change URI below.
deb [arch=amd64,arm64] https://dlm.mariadb.com/repo/mariadb-server/10.4/repo/ubuntu bionic main

deb [arch=amd64,arm64 lang=none target-=CNF] https://dlm.mariadb.com/repo/mariadb-server/10.4/repo/ubuntu bionic main/debug

# MariaDB MaxScale
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
deb [arch=amd64] https://dlm.mariadb.com/repo/maxscale/latest/apt bionic main

# MariaDB Tools
deb [arch=amd64] http://downloads.mariadb.com/Tools/ubuntu bionic main

インストール可能なパッケージの「一覧」を更新する。

$ sudo apt-get -y update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:2 https://dlm.mariadb.com/repo/mariadb-server/10.4/repo/ubuntu bionic InRelease [6265 B]
・・・(略)

インストール済みのパッケージ更新をおこない、新しいバージョンにアップグレードする。

kmri18@DESKTOP-OAP1VIU:/etc/apt/sources.list.d$ sudo apt-get -y upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
・・・(略)

mariadb-serverを表示

$ apt list | grep -i mariadb-server

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

mariadb-server/unknown,unknown 1:10.4.22+maria~bionic all
mariadb-server-10.1/bionic-updates,bionic-security 1:10.1.48-0ubuntu0.18.04.1 amd64
mariadb-server-10.4/unknown 1:10.4.22+maria~bionic amd64
mariadb-server-10.4-dbgsym/unknown 1:10.4.22+maria~bionic amd64
mariadb-server-core-10.1/bionic-updates,bionic-security 1:10.1.48-0ubuntu0.18.04.1 amd64
mariadb-server-core-10.4/unknown 1:10.4.22+maria~bionic amd64
mariadb-server-core-10.4-dbgsym/unknown 1:10.4.22+maria~bionic amd64

mariadb-server-10.4をインストール

$ sudo apt install mariadb-server-10.4 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
・・・(略)

$ dpkg -l | grep -i mariadb
ii  libdbd-mysql-perl              4.046-1
                amd64        Perl5 database interface to the MariaDB/MySQL database
ii  libmariadb3:amd64              1:10.4.22+maria~bionic              amd64        MariaDB database client library
ii  mariadb-client-10.4            1:10.4.22+maria~bionic              amd64        MariaDB database client binaries
ii  mariadb-client-core-10.4       1:10.4.22+maria~bionic              amd64        MariaDB database core client binaries
ii  mariadb-common                 1:10.4.22+maria~bionic              all          MariaDB database common files (e.g. /etc/mysql/mariadb.conf.d/)
ii  mariadb-server-10.4            1:10.4.22+maria~bionic              amd64        MariaDB database server binaries
ii  mariadb-server-core-10.4       1:10.4.22+maria~bionic              amd64        MariaDB database core server files

最後に、MySQLサーバーに接続する。

$ sudo mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.4.22-MariaDB-1:10.4.22+maria~bionic mariadb.org binary distribution

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のバージョンが10.4になっていることを確認しインストール終了。

まとめ

結果的にUbuntuの再インストールが解決へとつながった。
まざまな方法を試していると乱雑な環境となり意図せぬエラーが生じてしまうと考えられるため、環境のリセットも今後選択肢にいれようと思う。

参考

Ubuntu 18.04 LTS に MariaDB 10.4 をインストール

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