### 解決したいこと

wsl2でmysqlがインストール出来ません。1つ前の質問のエラーがどうしても解消出来なかったので、brewコマンドを使い、wsl2でmysqlをインストールしてしまいました。参考にした記事はマックのものだったので、ちゃんと実行すべきかよく考えるべきでした(wsl2でbrewを使ってmysqlをインストールするという記事はなかった)。結局途中で出たエラーが解決出来なかったのでアンインストールして正式な方法でインストールし直すことにしました。ですが、ここでエラーが発生してしまいました。

```

    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt install mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed:
      mysql-server
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    Need to get 0 B/9544 B of archives.
    After this operation, 113 kB of additional disk space will be used.
    Selecting previously unselected package mysql-server.
    (Reading database ... 43180 files and directories currently installed.)
    Preparing to unpack .../mysql-server_8.0.28-0ubuntu0.20.04.3_all.deb ...
    Unpacking mysql-server (8.0.28-0ubuntu0.20.04.3) ...
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                              dpkg: dependency problems prevent configuration of mysql-server:
     mysql-server depends on mysql-server-8.0; however:
      Package mysql-server-8.0 is not configured yet.
    
    dpkg: error processing package mysql-server (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     mysql-server-8.0
     mysql-server
    
```

間違って以前のログを消してしまったので、正確にはこのエラー画面ではない（このエラーは現在出ているエラー）のですが、内容は同じで依存関係に関するものでした。このエラーを解決するために、

<https://stackoverflow.com/questions/67564215/problems-installing-mysql-on-
ubuntu-20-04>

この方の記事を参考にしてコマンドを実行しました。この時はコマンドが成功し、一見直ったかのように思い、再度mysqlのインストールを試みるも同じエラーが出てしまいました。参考にしたのはこのサイトです  
<https://docs.microsoft.com/ja-jp/windows/wsl/tutorials/wsl-database>

この時私は恐らくbrewを使ってインストールしたことが原因で依存関係がおかしくなってしまったのだと思い、homebrewをアンインストールしました。その後もう一度インストールを試そうと思ったらまた同じエラーが出てしまい、詰まってしまいました。更に困った事に、先ほどまで使えたコマンドが使えなくなってしまいました。このサイト  
<https://stackoverflow.com/questions/67564215/problems-installing-mysql-on-
ubuntu-20-04>  
のコマンドを実行しても

```

    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt autoremove
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
      libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
      libio-html-perl liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8
      mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
    0 upgraded, 0 newly installed, 24 to remove and 0 not upgraded.
    1 not fully installed or removed.
    After this operation, 262 MB disk space will be freed.
    Do you want to continue? [Y/n] Y
    (Reading database ... 43180 files and directories currently installed.)
    Removing mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    Removing libcgi-fast-perl (1:2.15-1) ...
    Removing libhtml-template-perl (2.97-1) ...
    Removing libcgi-pm-perl (4.46-1) ...
    Removing libhttp-message-perl (6.22-1) ...
    Removing libencode-locale-perl (1.05-1) ...
    Removing mysql-server-core-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    Removing libevent-pthreads-2.1-7:amd64 (2.1.11-stable-1) ...
    Removing libevent-core-2.1-7:amd64 (2.1.11-stable-1) ...
    Removing libfcgi-perl (0.79-1) ...
    Removing libhtml-parser-perl (3.72-5) ...
    Removing libhtml-tagset-perl (3.20-4) ...
    Removing libhttp-date-perl (6.05-1) ...
    Removing libio-html-perl (1.001-1) ...
    Removing liblwp-mediatypes-perl (6.04-1) ...
    Removing mecab-ipadic-utf8 (2.7.0-20070801+main-2.1) ...
    update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
    Removing mecab-ipadic (2.7.0-20070801+main-2.1) ...
    Removing mecab-utils (0.996-10build1) ...
    Removing libmecab2:amd64 (0.996-10build1) ...
    Removing libtimedate-perl (2.3200-1) ...
    Removing liburi-perl (1.76-2) ...
    Removing mysql-client-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    Removing mysql-client-core-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    Removing mysql-common (5.8+1.0.5ubuntu2) ...
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package 'mysql-server' is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt purge mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package 'mysql-server' is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt autoclean
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt remove dbconfig-mysql
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package 'dbconfig-mysql' is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo systemctl stop mysql
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Note, selecting 'mysql-server-core-5.5' for glob 'mysql-server-core-*'
    Note, selecting 'mysql-server-core-5.6' for glob 'mysql-server-core-*'
    Note, selecting 'mysql-server-core-5.7' for glob 'mysql-server-core-*'
    Note, selecting 'mysql-server-core-8.0' for glob 'mysql-server-core-*'
    Package 'mysql-server-core-5.7' is not installed, so not removed
    Package 'mysql-server-core-5.5' is not installed, so not removed
    Package 'mysql-server-core-5.6' is not installed, so not removed
    Note, selecting 'mysql-client-core-5.5' for glob 'mysql-client-core-*'
    Note, selecting 'mysql-client-core-5.6' for glob 'mysql-client-core-*'
    Note, selecting 'mysql-client-core-5.7' for glob 'mysql-client-core-*'
    Note, selecting 'mysql-client-core-8.0' for glob 'mysql-client-core-*'
    Package 'mysql-client-core-5.7' is not installed, so not removed
    Package 'mysql-client-core-5.5' is not installed, so not removed
    Package 'mysql-client-core-5.6' is not installed, so not removed
    Package 'mysql-client' is not installed, so not removed
    Package 'mysql-client-core-8.0' is not installed, so not removed
    reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
    reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
    reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
    reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
    reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
    reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
    reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
    reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
    emitting matrix      : 100% |###########################################|
    
    done!
    update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
    Setting up libhtml-parser-perl (3.72-5) ...
    Setting up libhttp-message-perl (6.22-1) ...
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    Setting up libcgi-pm-perl (4.46-1) ...
    Setting up libhtml-template-perl (2.97-1) ...
    dpkg: dependency problems prevent configuration of mysql-server:
     mysql-server depends on mysql-server-8.0; however:
    Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
    Errors were encountered while processing:
     mysql-server-8.0
     mysql-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt autoremove
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    2 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    
    dpkg: error processing package mysql-server (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     mysql-server-8.0
     mysql-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt remove --purge mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
      libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
      libio-html-perl liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8
      mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
    Use 'sudo apt autoremove' to remove them.
    The following packages will be REMOVED:
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    Errors were encountered while processing:
     mysql-server-8.0
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt purge mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package 'mysql-server' is not installed, so not removed
    The following packages were automatically installed and are no longer required:
      libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    Errors were encountered while processing:
     mysql-server-8.0
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt autoclean
    Reading package lists... Done
    Building dependency tree
     mysql-server-8.0
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt remove --purge mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package 'mysql-server' is not installed, so not removed
    The following packages were automatically installed and are no longer required:
      libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
      libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
      libio-html-perl liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8
      mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
    Use 'sudo apt autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    Errors were encountered while processing:
     mysql-server-8.0
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    senseiy@senseIY-wsl:~/dictum/dictum$ sudo apt install mysql-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed:
      mysql-server
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    1 not fully installed or removed.
    Need to get 0 B/9544 B of archives.
    After this operation, 113 kB of additional disk space will be used.
    Selecting previously unselected package mysql-server.
    (Reading database ... 43180 files and directories currently installed.)
    Preparing to unpack .../mysql-server_8.0.28-0ubuntu0.20.04.3_all.deb ...
    Unpacking mysql-server (8.0.28-0ubuntu0.20.04.3) ...
    Setting up mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
    update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
    No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                              dpkg: dependency problems prevent configuration of mysql-server:
     mysql-server depends on mysql-server-8.0; however:
      Package mysql-server-8.0 is not configured yet.
    
    dpkg: error processing package mysql-server (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     mysql-server-8.0
     mysql-server
    
```

このようにすべてのコマンドでエラーが出てしまうようになってしまいました。どうすればいいのか分かりません。何かしらアドバイスがあればよろしくお願いいたします。
CC BY-SA 4.0
2022-03-08T04:05:41.377
86745
2022-03-08T05:10:21.023
2022-03-08T04:52:19.220
51193
51193
question
ruby-on-rails mysql wsl homebrew
wsl2でmysqlがインストール出来ない
どうしても解決出来ないので、wsl2を初期化することにしました。ご協力ありがとうございました。
CC BY-SA 4.0
2022-03-08T05:10:21.023
86749
2022-03-08T05:10:21.023
51193
86745
answer