PA-*_*-GW 8 server mysql 20.04
我已经清除并重新安装了 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
Run Code Online (Sandbox Code Playgroud)
然后我重新启动,什么也没发生。
命令输出:
mysql -V
mysql Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
Run Code Online (Sandbox Code Playgroud)
须藤 systemctl 状态 mysql.service
Unit mysql.service could not be found.
Run Code Online (Sandbox Code Playgroud)
须藤 systemctl 启动 mysql.service
Failed to start mysql.service: Unit mysql.service not found.
Run Code Online (Sandbox Code Playgroud)
须藤 systemctl 启动 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/
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。谢谢你。
<------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)
Run Code Online (Sandbox Code Playgroud)
ls -laF /lib/systemd/system/mysql.service
-rw-r--r-- 1 root root 524 Nov 6 11:34 /lib/systemd/system/mysql.service
Run Code Online (Sandbox Code Playgroud)
得到这个错误:: 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)
Run Code Online (Sandbox Code Playgroud)
须藤 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
Run Code Online (Sandbox Code Playgroud)
Exp*_*ate 14
尝试
sudo apt-get install --reinstall mysql-server-8.0
Run Code Online (Sandbox Code Playgroud)
并检查 mysql.service 是否存在
ls -laF /lib/systemd/system/mysql.service
Run Code Online (Sandbox Code Playgroud)
修复损坏的包
sudo apt-get install -f
sudo dpkg --configure -a
Run Code Online (Sandbox Code Playgroud)
修复旧安装遗留下来的 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
Run Code Online (Sandbox Code Playgroud)
小智 5
关于这个特定的错误:
Unit mysql.service could not be found.
Run Code Online (Sandbox Code Playgroud)
[我正在运行 Ubuntu 20.04]
我花了几个小时才发现这个:几个月前我玩过 MariaDB 并卸载了它,但显然它没有完全/干净地卸载。它留下了两个符号链接
ls /etc/systemd/system
mysql.service -> /lib/systemd/system/mariadb.service
mysqld.service -> /lib/systemd/system/mariadb.service
Run Code Online (Sandbox Code Playgroud)
链接的文件不是由链接本身删除的。我在两个链接上都运行了“取消链接”,卸载了所有 mysql 包dpkg -P
并重新安装,结果很好。
[我正在运行 Ubuntu 20.04] 祝你好运。
归档时间: |
|
查看次数: |
23399 次 |
最近记录: |