以下是步驟
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
$ sudo add-apt-repository 'deb [arch=amd64,i386] http://mirror.fibergrid.in/mariadbrepo/10.1/ubuntu xenial main'
sudo apt-get update
sudo apt-get install mariadb-server
錯誤
sudo: /etc/sudoers.d is world writable
Reading package lists... Done
Building dependency tree
Reading state information... Done
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:
mariadb-server : Depends: mariadb-server-10.1 (= 10.1.14+maria-1~trusty) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
答案1
請檢查您的機器中是否存在 Apache 和 php 軟體包。
請依照以下步驟徹底刪除 MySQL
現在打開終端機Ctrl+T
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
安裝阿帕契
sudo apt-get install apache2
安裝php
sudo apt-get install libapache2-mod-php mysql-server mysql-client
sudo mysql_install_db
sudo mysql_secure_installation
現在在終端機中開啟mysql
mysql -u root -p
請注意 php 的版本。參考為什麼選擇 php 7
如果您想要版本 5 php.ini,這是透過新增 ppa 來安裝 php 5 的一種方法。
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
其他參考:php版本問題
謝謝阿傑
答案2
就我而言,ibdata1 檔案已損壞。我修復如下:
$ sudo apt-get purge mariadb-*
$ sudo rm -f /var/lib/mysql/ib*
$ sudo apt-get install mariadb-server
答案3
如果您之前安裝過 MariaDB/MySQL 伺服器,請先刪除:
sudo apt-get remove mariadb-server mariadb-client mysql-server mysql-client
然後確保沒有 mysqld 進程正在運行。
sudo kill -9 $(pgrep mysql)
之後,安裝 MariaDB 伺服器。如果您仍然看到相同的錯誤,您應該檢查MariaDB錯誤日誌/var/log/mysql/error.log以找出原因。
答案4
以下是在 Ubuntu 系統上安裝 MariaDB 所需執行的命令:
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386] http://mirrors.hustunique.com/mariadb/repo/10.1/ubuntu xenial main'
導入金鑰並新增儲存庫後,您可以使用以下命令安裝 MariaDB:
sudo apt-get update
sudo apt-get install mariadb-server