1. 程式人生 > >Ubuntu重裝mysql錯誤解決

Ubuntu重裝mysql錯誤解決

span 安裝包 dpkg exe it is bubuko orm 權限 div

新搭建的服務器,先在Ubuntu上安裝mariadb,後來由於很多權限問題,決定安裝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).

通過閱讀錯誤信息可知,主要是因為依賴關系出現問題,主要思路是重建依賴關系,然後幹凈卸載,最後重裝。

首先,更新系統

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 update
sudo apt-get install mysql-server mysql-client

總結:

整體思路還是重建依賴關系,幹凈卸載,更新安裝。希望對遇到相同問題不知所措的小夥伴有所啟發、幫助。謝謝。

Ubuntu重裝mysql錯誤解決