我正在尝试在 Ubuntu 上安装 MySQL,我花了 3 天时间清除 MySQL 并重新下载,但没有成功。我发现的大多数解决方案都不适合我,它们都是删除 MySQL 并重新下载的一些变体。我也尝试过手动进入文件并手动删除所有 MySQL 相关文件。我也尝试过重新安装一些 dpkg 文件,但正如你所知,我对此还很陌生。我怎样才能解决这个问题?
alvin@DESKTOP-DAIIHEJ:~$ sudo apt-get install mysql-server
[sudo] password for alvin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (8.0.27-0ubuntu0.20.04.1).
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.
Do you want to continue? [Y/n] y
Setting up mysql-server-8.0 (8.0.27-0ubuntu0.20.04.1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ]
Renaming removed key_buffer and myisam-recover options (if present)
Cannot open /proc/net/unix: No such file or directory
Cannot stat file /proc/1/fd/5: Operation not permitted
Cannot stat file /proc/1/fd/10: Operation not permitted
Cannot stat file /proc/1/fd/6: Operation not permitted
Cannot stat file /proc/10/fd/7: Operation not permitted
Cannot stat file /proc/10/fd/10: Operation not permitted
Cannot stat file /proc/10/fd/5: Operation not permitted
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 143
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess 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-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
E: Sub-process /usr/bin/dpkg returned an error code (1)
这是我的错误日志
2022-01-27T22:38:25.061002Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.27-0ubuntu0.20.04.1).
2022-01-27T22:38:25.981554Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu).
2022-01-27T22:38:26.615434Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27-0ubuntu0.20.04.1) starting as process 206
2022-01-27T22:38:26.629831Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-01-27T22:38:26.648358Z 1 [ERROR] [MY-012585] [InnoDB] Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
2022-01-27T22:38:26.648440Z 1 [Warning] [MY-012654] [InnoDB] Linux Native AIO disabled.
2022-01-27T22:38:26.787334Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-01-27T22:38:26.848746Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2022-01-27T22:38:26.946919Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2022-01-27T22:38:26.946963Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2022-01-27T22:38:26.948630Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-01-27T22:38:26.948712Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-01-27T22:38:26.949587Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Permission denied
2022-01-27T22:38:26.949630Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?
2022-01-27T22:38:26.949908Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-01-27T22:38:27.949853Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu).
这是结果mount | grep proc
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) –
答案1
上述问题可以有多种解决方案
1. 重新配置dpkg包
此错误的触发因素之一是 dpkg 数据库损坏。可以通过以下方式修复sudo dpkg --configure -a
2. 强制安装有问题的包
有时,软件包安装过程中可能会出现错误。发生这种情况时,您可以使用 -f 选项强制安装软件包,如下所示。
sudo apt install -f
OR
sudo apt install --fix-broken
3. 清除不良或损坏的软件包
sudo apt remove --purge package_name
4.删除与包关联的所有文件
最后,您可以手动删除所有与麻烦的软件包相关的内容。首先,您需要找到位于 /var/lib/dpkg/info 目录中的这些文件。
sudo ls -l /var/lib/dpkg/info | grep -i package_name
列出文件后,您可以将它们移动到 /tmp 目录。
sudo mv /var/lib/dpkg/info/package-name.* /tmp
最后,更新包列表。
sudo apt update
然后尝试重新安装您的软件包。
您收到的错误是 Mysql 无法安装,因为端口 3306 已在使用中。
您可以使用netstat -lp | grep 3306
找出哪个程序已经在端口 3306 上侦听(您应该在最后一列中看到 PID/程序名称)并停止该程序(也许 mysql 已经在运行?)。
或者,您可以在不同的端口上启动新安装的服务器。 (编辑my.cnf
并更改那里的默认端口)
答案2
我通过更改端口解决了这个问题,因为我已经有一个 MariaBD 实例在同一实例中运行 $vi /etc/mysql/mysql.conf.d/mysqld.cnf
port = 3306
为了
port = 3366
感谢您分享您的知识!
答案3
我不知道这个答案是否有用。我在安装nodejs 18时遇到了这个问题。这个问题有时是由于包的干扰而发生的。以下命令对我有用
sudo apt autoremove
然后我安装了这个包
apt install -y -f <package>
答案4
sudo apt --fix-broken install
为我工作。我有一个未满足依赖关系的包。