mariaDB的安装持续了很长时间,结束了终端进程。
$ sudo apt-get install mariadb-server mariadb-client
尝试再次安装 MariaDB 导致以下问题:
Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 31891 (apt-get) - open (11: Resource temporarily unavailable)
因此我找到了以下解决方案。
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/cache/apt/archives/lock
$ sudo rm /var/lib/dpkg/lock*
$ sudo dpkg --configure -a
$ sudo apt update
但这也出现了一些问题:
$ sudo dpkg --configure -a
Setting up mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
^Cdpkg: error processing package mariadb-server-10.3 (--configure):
installed mariadb-server-10.3 package post-installation script subprocess was interrupted
dpkg: dependency problems prevent configuration of mariadb-server:
mariadb-server depends on mariadb-server-10.3 (>= 1:10.3.22-0ubuntu0.19.10.1); however:
Package mariadb-server-10.3 is not configured yet.
dpkg: error processing package mariadb-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mariadb-server-10.3
mariadb-server
我删除并重新安装了MariaDB,但是安装很长时间都没有完成。
$ sudo apt-get install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3
mariadb-server-core-10.3
Suggested packages:
mailx mariadb-test tinyca
The following NEW packages will be installed:
mariadb-client mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server
mariadb-server-10.3 mariadb-server-core-10.3
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17.3 MB of archives.
After this operation, 158 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mariadb-common.
(Reading database ... 212987 files and directories currently installed.)
Preparing to unpack .../mariadb-common_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...
Unpacking mariadb-common (1:10.3.22-0ubuntu0.19.10.1) ...
Selecting previously unselected package mariadb-client-core-10.3.
Preparing to unpack .../mariadb-client-core-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...
Unpacking mariadb-client-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Selecting previously unselected package mariadb-client-10.3.
Preparing to unpack .../mariadb-client-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...
Unpacking mariadb-client-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Selecting previously unselected package mariadb-server-core-10.3.
Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...
Unpacking mariadb-server-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Setting up mariadb-common (1:10.3.22-0ubuntu0.19.10.1) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.3.
(Reading database ... 213145 files and directories currently installed.)
Preparing to unpack .../mariadb-server-10.3_1%3a10.3.22-0ubuntu0.19.10.1_amd64.deb ...
Unpacking mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Selecting previously unselected package mariadb-client.
Preparing to unpack .../mariadb-client_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...
Unpacking mariadb-client (1:10.3.22-0ubuntu0.19.10.1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../mariadb-server_1%3a10.3.22-0ubuntu0.19.10.1_all.deb ...
Unpacking mariadb-server (1:10.3.22-0ubuntu0.19.10.1) ...
Setting up mariadb-server-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Setting up mariadb-client-core-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Setting up mariadb-client-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Setting up mariadb-server-10.3 (1:10.3.22-0ubuntu0.19.10.1) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
答案1
如果你之前安装过 mySQL,并且你的系统日志显示
AVC apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld"
当使用库存的 Ubuntu/Debian 仓库时,清除、重新安装或类似操作都无济于事。
残留的 AppArmor 配置文件将阻止 mariaDB 成功启动。
因此实际上任何想要在 Debian 或 Ubuntu 上从 mySQL 切换到 mariaDB 的人都会失败(可能是某些 Oracle 维护人员参与了软件包创建?;-))
这是从 18.04 版开始已知的,包括一个修复,但直到现在还没有修复。
https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263
echo "/usr/sbin/mysqld { }" > /etc/apparmor.d/usr.sbin.mysqld
apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
将会修复此问题。之后,可以安装 mariaDB 和/或启动服务。
答案2
我正在使用 ubuntu 20.04 并且有同样的经历。(mariadb-server-10.3)
毕竟,我更新了 mariadb 存储库
https://downloads.mariadb.org/mariadb/repositories
并安装 mariadb-server-10.5
[安装进度]
- 选择发行版:Ubuntu
- 选择一个版本:20.04“focal”——就我而言
- 选择版本:10.5 [稳定版]
- 选择镜像:按“显示所有镜像”按钮,然后单击“DigitalOcean - 美国纽约”
- 有些镜像不起作用,因为获取密钥无效 - 所需进度将显示在下面。
sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el]http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.5/ubuntu焦点主要'
sudo apt update
sudo apt install mariadb-server