我在 ubuntu 21.04 上运行 mysql 时遇到困难。我试过:
sudo apt remove --purge mysql-server
sudo apt purge mysql-server
sudo apt autoremove
sudo apt autoclean
和
sudo systemctl stop mysql
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo apt autoremove
sudo apt autoclean
重新安装 mysql-server 之前:
sudo apt update
sudo apt install mysql-server
但无济于事。问题是,当我安装时,我在终端中看到这个:
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我运行时sudo mysql
,出现此错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
当我跑步时systemctl status mysql
我得到:
mysql.service - MySQL Community Server
Loaded: error (Reason: Unit mysql.service failed to load properly: Device or resource busy.)
Active: failed (Result: exit-code) since Sun 2021-09-05 23:29:27 EET; 58min ago
Main PID: 31191 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
我试过:
sudo systemctl stop mysql
sudo systemctl start mysql
但我明白
Failed to start mysql.service: Unit mysql.service failed to load properly: Device or resource busy.
See system logs and 'systemctl status mysql.service' for details.
在 error.log 中我得到:
2021-09-05T22:26:37.674376Z 0 [错误] [MY-010262] [服务器] 无法启动服务器:绑定在 TCP/IP 端口上:地址已在使用中
2021-09-05T22:26:37.674517Z 0 [错误] [MY-010257] [服务器] 您是否已在端口 3306 上运行另一个 mysqld 服务器?
2021-09-05T22:26:37.674808Z 0 [错误] [MY-010119] [服务器] 正在中止
但当我运行的时候,netstat -lp | grep 3306
我发现端口 3306 上没有任何运行。我通过运行 sudo kill -9 $(sudo lsof -t -i:3306)
关于如何解决这个问题有什么想法吗?