新搭建的服務器,先在Ubuntu上安裝mariadb,後來因爲不少權限問題,決定安裝Mysql,在卸載過程當中因爲未卸載乾淨,致使mysql重裝過程當中出現了不少問題。mysql
Reading package lists...Done Building dependency tree Reading state information ... Done mysql-server is already the newest version(5.7.21-0ubuntu0.16.04.1). You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: mysql-server: depends: mysql-server-5.7 but it is not going to be installed E: Unmet dependencies.Try 'apt-get -f install' with no packages(or specify a solution).
經過閱讀錯誤信息可知,主要是由於依賴關係出現問題,主要思路是重建依賴關係,而後乾淨卸載,最後重裝。sql
首先,更新系統ubuntu
sudo apt-get update
而後,修復安裝錯誤,會提示輸入mysql用戶名密碼bash
sudo apt-get --fix-broken install
而後,檢索mysql安裝包,並刪除檢索出的依賴包,而後是刪除/var/lib/mysql,最後重裝mysql。服務器
下面我把檢索到的解決方法展現給你們:ui
We excute the following commands to solve the above problem: 1.Get the list of MySQL packages installed on the system by executing the command sudo dpkg -l grep mysql 2.Remove the packages shown above by executing the command sudo apt-get --purge autoremove <packages from the step 1> 3. Delete /var/lib/mysql 4.Try to install mysql again.It should solve your problem.
第二步中的packages以下圖所示:spa
最後就是更新系統並重裝mysqlcode
sudo apt-get update sudo apt-get install mysql-server mysql-client
總結:orm
總體思路仍是重建依賴關係,乾淨卸載,更新安裝。但願對遇到相同問題不知所措的小夥伴有所啓發、幫助。謝謝。server