Mysql-clientとサーバーを数回パージして再インストールしましたが、システムを再起動しましたが、コンピューターでmysqlを機能させることができません。
別のaskubuntuの投稿に従って、これらのコマンドを実行しました。
Sudo apt-get --purge remove mysql-server mysql-common mysql-client.
Sudo apt update && Sudo apt dist-upgrade && Sudo apt autoremove.
Sudo apt-get install -y mysql-server mysql-client
その後、再起動しても何も起こりませんでした。
コマンドの出力:
mysql -V
mysql Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
Sudo systemctl status mysql.service
Unit mysql.service could not be found.
Sudo systemctl start mysql.service
Failed to start mysql.service: Unit mysql.service not found.
Sudo systemctl start mysqld.service
Failed to start mysqld.service: Unit mysqld.service not found
削除してパージしましたが、mysqlがインストールされているだけで動作していないようです。
mysql -h localhost -P 3306 -u root -pまたはmysql -h 127.0.0.1 -P 3306 -u root -p
同じ結果:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
cat mysql.cnf 1 ↵
#
# 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
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
どんな助けでもありがたいです。ありがとうございました。
<------ UPDATE ------>コメントで推奨されているコマンドを実行しただけで、これが出力です。
Sudo apt-get install --reinstall mysql-server-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/1,228 kB of archives.
After this operation, 0 B of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 326219 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.20-0ubuntu0.20.04.1_AMD64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: old mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-8.0_8.0.20-0ubuntu0.20.04.1_AMD64.deb (--unpack):
new mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-8.0_8.0.20-0ubuntu0.20.04.1_AMD64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
ls -laF /lib/systemd/system/mysql.service
-rw-r--r-- 1 root root 524 Nov 6 11:34 /lib/systemd/system/mysql.service
このエラーが発生しました:: Sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,228 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package mysql-server-8.0 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
Sudo dpkg --configure -a
dpkg: error processing package mysql-server-8.0 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
mysql-server-8.0
試す
Sudo apt-get install --reinstall mysql-server-8.0
mysql.serviceが存在するかどうかを確認します
ls -laF /lib/systemd/system/mysql.service
壊れたパッケージを修正するには
Sudo apt-get install -f
Sudo dpkg --configure -a
古いインストールから残っている可能性があるmysql.serviceを修正します
Sudo killall mysqld
Sudo systemctl disable mysql.service
Sudo rm -rf /lib/systemd/system/mysql.service
Sudo rm -rf /usr/lib/systemd/system/mysql.service
Sudo rm -rf /etc/systemd/system/multi-user.target.wants/mysql.service
Sudo rm -rf /var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/mysql.service
Sudo rm -rf /var/cache/apt/archives/mysql-server-*.deb
Sudo apt-get install -f
Sudo dpkg --configure -a
Sudo apt-get install --reinstall mysql-server-8.0