1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UbuntuにMySQL8.0をインストールする

Last updated at Posted at 2021-02-06

はじめに

すべては以下のエラーから始まりました。

System has not been booted with systemd as init system (PID 1). Can't operate.

ubuntuにmysqlをインストールしたかっただけなのに手順がややこしかったのでまとめます。

環境

  • windows 10 Home
  • Ubuntu 20.04
  • wsl2

ややこしくなった原因

wsl2を使用していなかった

ubuntuではsystemctlが使えないらしく、使えるようにするためにはwsl2が必要でした。自分はwsl1を使っていたのでwsl2を導入する分手間が増えました。

実際にやった手順

  • mysqlをインストール

mysqlは公式ホームページでインストール方法を調べてその手順通りインストールを行いました。
インストール方法が何個かありその中からUbuntu 20.04に対応した方法を探すのが手間だったので、自分が参考にしたURLを載せときます。
Ubuntu 20.04 | MySQLインストールで参考にした記事
とりあえず手順3までやり以下のパッケージをインストールしました。
sudo apt install mysql-client-core-8.0

  • wsl1 -> wsl2にする

以下の記事を参考にしました。
https://www.kkaneko.jp/tools/wsl/wsl2.html
https://docs.microsoft.com/en-us/windows/wsl/install-win10
この部分は手順が分かりやすくまとまっていて記事通りにやれば問題ありませんでした。
自分はもともとUbuntuを導入していたので、Ubuntuのインストール部分は手順を省略しました。

  • wsl2でsystemctlを使えるようにする

以下の記事を参考にしました。

一つ目の記事はsystemctlが使えない原因が書かれています。ここからwsl2でsystemctlを使えるようにするgenieというパッケージを知りました。
二つ目の記事はgenieのGitHubです。genieのインストール方法がREADMEに書かれています。依存関係があったためこの手順も簡単にまとめときます。

  • genieのインストール
  1. .NET SDKをインストールする
    Ubuntu20.04の場合、以下の記事が参考になります。
    Ubuntu20.04 | .NET SDKをインストールする

  2. wsl-transdebianのインストール
    https://arkane-systems.github.io/wsl-transdebian/

  3. genieのインストール

$ sudo apt update
$ sudo apt install -y systemd-genie

// genieをインストール後以下のコマンドを実行

$ genie -s 

以上です。

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?