web-dev-qa-db-ja.com

Ubuntuの更新後にMySQLを更新または削除できません

2日前、サーバーをXenialバージョンに更新しましたが、何らかの理由でMySQL構成が完全に壊れました。だから、私はそれを更新、削除しようとしましたが、うまくいかなかったので、私はオンラインで見つけた多くのアイデアを試しました...しかし、どれもうまくいかず、まだこのMySQLインストールの問題に悩まされています。だから、私はいくつかの助けを求める時だと思う...

問題の特定に役立つ可能性のある情報を次に示します。

Sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Sudo apt-get purge mysql *

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'mysqltcl' for glob 'mysql*'
Note, selecting 'mysql-mmm-agent' for glob 'mysql*'
Note, selecting 'mysql-workbench' for glob 'mysql*'
Note, selecting 'mysql-client-5.1' for glob 'mysql*'
Note, selecting 'mysql-client-5.5' for glob 'mysql*'
Note, selecting 'mysql-client-5.6' for glob 'mysql*'
Note, selecting 'mysql-client-5.7' for glob 'mysql*'
Note, selecting 'mysql-mmm-tools' for glob 'mysql*'
Note, selecting 'mysql-common-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-5.0' for glob 'mysql*'
Note, selecting 'mysql-server-5.1' for glob 'mysql*'
Note, selecting 'mysql-server-5.5' for glob 'mysql*'
Note, selecting 'mysql-server-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-5.7' for glob 'mysql*'
Note, selecting 'mysql-utilities' for glob 'mysql*'
Note, selecting 'mysql-testsuite' for glob 'mysql*'
Note, selecting 'mysql-mmm-common' for glob 'mysql*'
Note, selecting 'mysql-server' for glob 'mysql*'
Note, selecting 'mysql-client' for glob 'mysql*'
Note, selecting 'mysql-sandbox' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.5' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.6' for glob 'mysql*'
Note, selecting 'mysql-client-core-5.7' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.5' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.6' for glob 'mysql*'
Note, selecting 'mysql-testsuite-5.7' for glob 'mysql*'
Note, selecting 'mysql-common' for glob 'mysql*'
Note, selecting 'mysql-mmm-monitor' for glob 'mysql*'
Note, selecting 'mysqltuner' for glob 'mysql*'
Note, selecting 'mysql-workbench-data' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.1' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.5' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.6' for glob 'mysql*'
Note, selecting 'mysql-server-core-5.7' for glob 'mysql*'
Note, selecting 'mysql-source-5.7' for glob 'mysql*'
Package 'mysql-client-5.5' is not installed, so not removed
Package 'mysql-client-5.6' is not installed, so not removed
Package 'mysql-server-core-5.6' 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
Note, selecting 'mysql-common' instead of 'mysql-common-5.6'
Package 'mysql-server-5.6' is not installed, so not removed
Package 'mysql-server-core-5.5' is not installed, so not removed
Package 'mysql-testsuite-5.5' is not installed, so not removed
Package 'mysql-testsuite-5.6' is not installed, so not removed
Package 'mysql-server-5.0' is not installed, so not removed
Package 'mysql-server-5.1' is not installed, so not removed
Package 'mysql-server-core-5.1' is not installed, so not removed
Package 'mysql-client-5.1' is not installed, so not removed
Package 'mysql-mmm-agent' is not installed, so not removed
Package 'mysql-mmm-common' is not installed, so not removed
Package 'mysql-mmm-monitor' is not installed, so not removed
Package 'mysql-mmm-tools' is not installed, so not removed
Package 'mysql-sandbox' is not installed, so not removed
Package 'mysql-utilities' is not installed, so not removed
Package 'mysql-workbench' is not installed, so not removed
Package 'mysql-workbench-data' is not installed, so not removed
Package 'mysqltcl' is not installed, so not removed
Package 'mysqltuner' is not installed, so not removed
Package 'mysql-source-5.7' is not installed, so not removed
Package 'mysql-testsuite' is not installed, so not removed
Package 'mysql-testsuite-5.7' is not installed, so not removed
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mariadb-client : Depends: mariadb-client-10.0 (>= 10.0.33-0ubuntu0.16.04.1) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

d pkg -l | grep -i mysql

ii  dbconfig-mysql                     2.0.4ubuntu1                               all          dbconfig-common MySQL/MariaDB support
ii  libdbd-mysql-Perl                  4.033-1ubuntu0.1                           AMD64        Perl5 database interface to the MySQL database
ii  libmysqlclient-dev                 5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database development files
ii  libmysqlclient18:AMD64             5.5.53-0ubuntu0.14.04.1                    AMD64        MySQL database client library
ii  libmysqlclient20:AMD64             5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database client library
ii  mysql-client                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database client (metapackage depending on the latest version)
ii  mysql-client-5.7                   5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database client binaries
ii  mysql-client-core-5.7              5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database core client binaries
ii  mysql-common                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
iU  mysql-server                       5.7.21-0ubuntu0.16.04.1                    all          MySQL database server (metapackage depending on the latest version)
rc  mysql-server-5.5                   5.5.53-0ubuntu0.14.04.1                    AMD64        MySQL database server binaries and system database setup
iF  mysql-server-5.7                   5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7              5.7.21-0ubuntu0.16.04.1                    AMD64        MySQL database server binaries
ii  mytop                              1.9.1-2                                    all          top like query monitor for MySQL
ii  php-mysql                          1:7.0+35ubuntu6                            all          MySQL module for PHP [default]
ii  php5-mysql                         5.5.9+dfsg-1ubuntu4.20                     AMD64        MySQL module for php5
ii  php7.0-mysql                       7.0.22-0ubuntu0.16.04.1                    AMD64        MySQL module for PHP
ii  phpmyadmin                         4:4.5.4.1-2ubuntu2                         all          MySQL web administration tool

Sudo apt-get purge dbconfig-mysql

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dbconfig-no-thanks
The following packages will be REMOVED:
  dbconfig-mysql*
The following NEW packages will be installed:
  dbconfig-no-thanks
0 upgraded, 1 newly installed, 1 to remove and 17 not upgraded.
2 not fully installed or removed.
Need to get 1,314 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 mirror://mirrors.ubuntu.com/mirrors.txt xenial/universe AMD64 dbconfig-no-thanks all 2.0.4ubuntu1 [1,314 B]
Fetched 1,314 B in 1s (994 B/s)         
dpkg: dbconfig-mysql: dependency problems, but removing anyway as you requested:
 phpmyadmin depends on dbconfig-mysql | dbconfig-no-thanks | dbconfig-common (<< 2.0.0); however:
  Package dbconfig-mysql is to be removed.
  Package dbconfig-no-thanks is not installed.
  Version of dbconfig-common on system is 2.0.4ubuntu1.

(Reading database ... 81675 files and directories currently installed.)
Removing dbconfig-mysql (2.0.4ubuntu1) ...
Selecting previously unselected package dbconfig-no-thanks.
(Reading database ... 81673 files and directories currently installed.)
Preparing to unpack .../dbconfig-no-thanks_2.0.4ubuntu1_all.deb ...
Unpacking dbconfig-no-thanks (2.0.4ubuntu1) ...
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script 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-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up dbconfig-no-thanks (2.0.4ubuntu1) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

この問題を解決するアイデアはありますか?

お時間をいただきありがとうございます。

--- EDIT ---

問題を修正しようとして、すべてのmy.cnfファイルが削除されました。だから私は次の内容を使用して/ etc/mysqlに新しいものを作成しようとしましたが、問題を解決するのに役立ちませんでした(「Sudo apt-get install mysql-server mysql-client」をしようとすると返されるエラーはまだ同じ)。

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

!includedir /etc/mysql/conf.d/

--- EDIT 2 ---

ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

Sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: warning: /etc/alternatives/my.cnf has been changed (manually or by a script); switching to manual updates only
update-alternatives: warning: forcing reinstallation of alternative /etc/mysql/my.cnf because link group my.cnf is broken
update-alternatives: warning: current alternative /etc/mysql/my.cnf is unknown, switching to /etc/mysql/mysql.cnf for link group my.cnf
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
chown: invalid user: ‘mysql:mysql’
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
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-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

--- EDIT 3 ---

Sudo apt-get install mysql-server mysql-client

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version (5.7.21-0ubuntu0.16.04.1).
mysql-server is already the newest version (5.7.21-0ubuntu0.16.04.1).
0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
update-alternatives: error: cannot stat file '/etc/mysql/mysql.cnf': Too many levels of symbolic links
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
2
Valkea

次の理由により、mysql-server-5.7のインストールに失敗しました。

エラー:代替パス/etc/mysql/mysql.cnfが存在しません

このエラーは、mysqlインストールのバグが原因である可能性があります。

/etc/mysql/my.cnfは存在すると仮定しますが、/ etc/mysql/mysql.cnfは存在しません。そのため、次の手順が役立つ場合があります。

  1. /etc/mysql/my.cnfからのシンボリックリンクの作成は、次のコマンドを使用して/etc/alternatives/my.cnfへのシンボリックリンクです:ln -s /etc/mysql/my.cnf /etc/alternatives/my.cnf

  2. /etc/alternatives/my.cnfから/etc/mysql/mysql.cnfへのデフォルトのシンボリックリンクが損なわれていないかどうかを確認します:ls -l /etc/alternatives/my*

  3. 出力に「そのようなファイルまたはディレクトリがありません」と表示された場合、次のコマンドでシンボリックリンクを作成します:ln -s /etc/alternatives/my.cnf /etc/mysql/mysql.cnf

  4. ここで、mysql-serverインストールを再度実行します。


[編集]

ええとああ。以前のアンインストールでほとんど問題が発生したようです。 mysqlを再び正しくインストールできるようになるまで、エラーを1つずつ修正しましょう。現在のエラー:

chown:無効なユーザー: 'mysql:mysql'

それを修正するために、その「mysql」ユーザーとその「mysql」グループをチェックしてみましょう(作成されていない場合)。

  • グループファイルを編集用に開きます:Sudo vi /etc/group(そのファイルの編集には注意してください!)
  • 「mysql」で始まる行を探します。

    • a)ある場合は、その行の最後にある番号を覚えておいてください。
    • b)そのような「mysql」行がない場合は、全体(!)リストで1xx番号が最大の行を探します。その後に新しい行を追加し、「mysql:x:GGG」と入力します(GGGを最大の1xx番号+1に置き換えます)。追加した行は、たとえばmysql:x:115のようになります。次に、そのファイルを保存して終了します。
  • ここで 'vi/etc/passwd'を開きます(このファイルも慎重に編集してください!)
  • 「mysql」のある行を探します。

    • a)存在する場合は、その行の2番目の番号を確認します。グループファイルで前に記憶/追加した番号と一致する必要があります。
    • b)そのような「mysql」行がない場合は、wohle(!)リストで1xx番号が最も大きい行を探します。その後に新しい行を追加し、「mysql:x:UUU:GGG:MySQL Server ,:/ nonexistent:/ bin/false」と入力します(UUUをこのファイルの最大番号1xx番号+1に置き換えます。GGGを以前にグループファイルの番号を記憶/追加しました。)。次に、そのファイルを保存して終了します。

    • ここで、mysql-serverを再度インストールしてください。

2
Bob