我已经清除并重新安装了 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 启动 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/
任何帮助表示赞赏。谢谢你。
<--------更新-----> 刚刚运行了评论中推荐的命令,这是输出:
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
尝试
并检查 mysql.service 是否存在
修复损坏的包
修复可能从旧安装中遗留下来的 mysql.service
关于这个特定的错误:
[我正在运行 Ubuntu 20.04]
我花了几个小时才发现这个:几个月前我玩过 MariaDB 并卸载了它,但显然它没有完全/干净地卸载。它留下了两个符号链接
链接文件已被链接本身删除。我在两个链接上都运行了“unlink”,卸载了所有 mysql 软件包
dpkg -P
并重新安装,结果很好。[我正在运行 Ubuntu 20.04] 祝你好运。
当这种情况发生在我身上时,我需要做的就是运行:
然后运行:
这删除了旧的符号链接并创建了新的符号链接。
我遇到了同样的问题,盲目地遵循所有先前的指示,但无济于事。为了解决这个问题,我做了以下事情。
我将 /etc/mysql/FROZEN 重命名为 _FROZEN
我运行了命令:
由于其中一行说要降级到 5.7(包括新的 /etc/mysql/FROZEN 文件)并且绝望,我试图降级 MySQL。
我注意到“mysql-server-5.7”被“mariadb-server-10.3”取代,所以我试了一下!
随后我去 Synaptic 检查损坏的软件包,并且“mysql-server-8.0”不再存在,也不再安装。