Ubuntu安裝MySQL遇到的問題

問題描述

今天在Ubuntu14.04下安裝mysql時遇到了問題。
一開始,我嘗試輸入以下命令:

mysql -u root -p

然后得到如下信息:

The program mysql can be found on the following packages:
mysql-client-core-5.5 
mariadb-client-core-5.5 
mysql-client-core-5.6 
percona-xtrabd-cluster-client-5.5

我鬼使神差地選擇了5.6的安裝包,輸入了

sudo apt-get install mysql-client-core-5.6

安裝完畢后我又一次嘗試連接mysql,得到如下錯誤信息:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

我嘗試輸入mysqld,得到以下提示:

The program mysql can be found on the following packages:
mysql-server-core-5.5 
mariadb-server-core-5.5 
mysql-server-core-5.6 
percona-xtrabd-cluster-server-5.5

對應(yīng)的我選擇了mysql-server-core-5.6
連接時還是得到上面的錯誤。
查閱資料后,我按照別人的方法依次輸入以下命令:

sudo apt-get clean && sudo apt-get update
sudo apt-get install mysql-server mysql-client

結(jié)果得到了如下信息

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
解決方法:

經(jīng)過查閱終于找到了問題的解決方法。版本依賴問題,MySQL客戶端5.5和MySQL服務(wù)器5.5是目前Ubuntu 14.04匹配地“最好”版本。

方法一:

移除5.6,安裝5.5

sudo apt-get purge mysql-client-core-5.6
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-client-core-5.5
sudo apt-get install mysql-server
方法二:

使用aptitude,其實也是移除5.6版本,安裝了5.5版本。未安裝aptitude的話先安裝aptitude

sudo apt-get install aptitude

然后輸入

sudo aptitude install mysql-server
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容