標籤:mysql system src rect 很多 bubuko 伺服器 dep mysql安裝
新搭建的伺服器,先在Ubuntu上安裝mariadb,後來由於很多許可權問題,決定安裝Mysql,在卸載過程中由於未卸載乾淨,導致mysql重裝過程中出現了很多問題。
Reading package lists...DoneBuilding dependency treeReading state information ... Donemysql-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 installedE: Unmet dependencies.Try ‘apt-get -f install‘ with no packages(or specify a solution).
通過閱讀錯誤資訊可知,主要是因為依賴關係出現問題,主要思路是重建依賴關係,然後乾淨卸載,最後重裝。
首先,更新系統
sudo apt-get update
然後,修複安裝錯誤,會提示輸入mysql使用者名稱密碼
sudo apt-get --fix-broken install
然後,檢索mysql安裝包,並刪除檢索出的依賴包,然後是刪除/var/lib/mysql,最後重裝mysql。
下面我把檢索到的解決方案展示給大家:
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如所示:
最後就是更新系統並重裝mysql
sudo apt-get updatesudo apt-get install mysql-server mysql-client
總結:
整體思路還是重建依賴關係,乾淨卸載,更新安裝。希望對遇到相同問題不知所措的小夥伴有所啟發、協助。謝謝。
Ubuntu重裝mysql錯誤解決