我正在尝试在 Ubuntu 上安装 MySQL,我花了 3 天时间清除 MySQL 并重新下载,但没有成功。我发现的大多数解决方案都不适合我,它们都是删除 MySQL 并重新下载的一些变体。我也尝试过手动进入文件并手动删除所有 MySQL 相关文件。我也尝试过重新安装一些 dpkg 文件,但正如你所知,我对此还很陌生。我怎样才能解决这个问题?
\nalvin@DESKTOP-DAIIHEJ:~$ sudo apt-get install mysql-server\n[sudo] password for alvin:\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nmysql-server is already the newest version (8.0.27-0ubuntu0.20.04.1).\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n2 not fully installed or removed.\nAfter this operation, 0 B of additional disk space will be used.\nDo you want to continue? [Y/n] y\nSetting up mysql-server-8.0 (8.0.27-0ubuntu0.20.04.1) ...\ninvoke-rc.d: could not determine current runlevel\n * Stopping MySQL database server mysqld [ OK ]\nRenaming removed key_buffer and myisam-recover options (if present)\nCannot open /proc/net/unix: No such file or directory\nCannot stat file /proc/1/fd/5: Operation not permitted\nCannot stat file /proc/1/fd/10: Operation not permitted\nCannot stat file /proc/1/fd/6: Operation not permitted\nCannot stat file /proc/10/fd/7: Operation not permitted\nCannot stat file /proc/10/fd/10: Operation not permitted\nCannot stat file /proc/10/fd/5: Operation not permitted\nmysqld will log errors to /var/log/mysql/error.log\nmysqld is running as pid 143\ndpkg: error processing package mysql-server-8.0 (--configure):\n installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1\nNo apport report written because the error message indicates its a followup error from a previous failure.\n dpkg: dependency problems prevent configuration of mysql-server:\n mysql-server depends on mysql-server-8.0; however:\n Package mysql-server-8.0 is not configured yet.\n\ndpkg: error processing package mysql-server (--configure):\n dependency problems - leaving unconfigured\nErrors were encountered while processing:\n mysql-server-8.0\n mysql-server\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n
Run Code Online (Sandbox Code Playgroud)\n这是我的错误日志
\n2022-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).\n2022-01-27T22:38:25.981554Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu).\n2022-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\n2022-01-27T22:38:26.629831Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.\n2022-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.\n2022-01-27T22:38:26.648440Z 1 [Warning] [MY-012654] [InnoDB] Linux Native AIO disabled.\n2022-01-27T22:38:26.787334Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.\n2022-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'\n2022-01-27T22:38:26.946919Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main\n2022-01-27T22:38:26.946963Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main\n2022-01-27T22:38:26.948630Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.\n2022-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.\n2022-01-27T22:38:26.949587Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Permission denied\n2022-01-27T22:38:26.949630Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?\n2022-01-27T22:38:26.949908Z 0 [ERROR] [MY-010119] [Server] Aborting\n2022-01-27T22:38:27.949853Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu).\n
Run Code Online (Sandbox Code Playgroud)\n这是结果mount | grep proc
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)\nbinfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) \xe2\x80\x93\n
Run Code Online (Sandbox Code Playgroud)\n
此错误的触发因素之一是 dpkg 数据库损坏。可以通过以下方式修复sudo dpkg --configure -a
有时,软件包安装过程中可能会出现错误。发生这种情况时,您可以使用 -f 选项强制安装软件包,如下所示。
sudo apt install -f
OR
sudo apt install --fix-broken
Run Code Online (Sandbox Code Playgroud)
sudo apt remove --purge package_name
最后,您可以手动删除所有与麻烦的软件包相关的内容。首先,您需要找到位于 /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
然后尝试重新安装您的软件包。
您可以使用netstat -lp | grep 3306
找出哪个程序已经在端口 3306 上侦听(您应该在最后一列中看到 PID/程序名称)并停止该程序(也许 mysql 已经在运行?)。
或者,您可以在不同的端口上启动新安装的服务器。(编辑my.cnf
并更改那里的默认端口)