我需要使用以下命令清除 MYSQL 的安裝:
sudo apt remove --purge mysql-server
sudo apt purge mysql-server
sudo apt autoremove
sudo apt autoclean
sudo apt remove dbconfig-mysql
一切似乎都清除得很好。
嘗試重新安裝更新檔案清單後出現以下錯誤:
Setting up mysql-server-8.0 (8.0.30-0ubuntu0.22.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
ERROR: Unable to start MySQL server:
mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory)
mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/mysql/my.cnf at l
ine 20.
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgr
ade issues.
Once the problem is resolved, run apt-get --fix-broken install to retry.
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit
status 1
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
No apport report written because the error message indicates its a followup error from a pre
vious failure.
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
我查看了維基鏈接,沒有幫助。我三年前在這裡看到了一篇類似的文章,嘗試了建議的“apt install -f”,但同樣沒有幫助。
答案1
在嘗試刪除 mysql 之前,請確保它已關閉sudo systemctl stop mysql
,然後再次嘗試發出命令。
停止 MySQL 服務後,您可以執行systemctl status mysql
以確保它已關閉。
讓我知道它是否有效。
[其他解決方案]
根據錯誤訊息建立目錄。
sudo mkdir -p /etc/mysql/conf.d/
建立一個新mysql.cnf
文件並寫入[mysql]
其中。
echo "[mysql]" | sudo tee /etc/mysql/conf.d/mysql.cnf
並重新配置包。
sudo dpkg --configure -a