安装MariaDB Community Server 10.6到Rocky Linux 8.5

CentOS 8 已于2021年12月31日到达了支持结束期(End of Life)。

我将在Rocky Linux 8上安装最新版的MariaDB Community Server。

下载 Rocky Linux 8.5。

从https://rockylinux.org/download/下载x86_64的可引导镜像(https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.5-x86_64-boot.iso),然后在VMware上引导。

设置yum仓库

执行以下一行命令,设置yum软件源。

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

如果不指定版本,则设置为10.6版本的仓库。如果要使用其他版本,则可以通过mariadb_repo_setup选项的–mariadb-server-version来指定版本号,或者通过将mariadb.repo文件中的baseurl中的10.6替换为其他版本号。

[mariadb-main]
name = MariaDB Server
baseurl = https://dlm.mariadb.com/repo/mariadb-server/10.6/yum/rhel/8/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1
module_hotfixes = 1

[mariadb-maxscale]
name = MariaDB MaxScale
baseurl = https://dlm.mariadb.com/repo/maxscale/latest/yum/rhel/8/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 1

[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/8/x86_64
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1

安装 MariaDB Community Server 10.6

由于本次是安装最新版本的 10.6,因此将直接安装 MariaDB-server。

dnf -y install MariaDB-server

运行MariaDB监视器

在最近的 MariaDB 版本中,您可以使用 mariadb 命令而非 mysql 命令来启动 MariaDB monitor。

$ sudo mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.5-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

2022年1月1日时,已安装10.6.5版本。

另外,为了保持向下兼容性,mysql 命令是一个指向 /usr/bin/mariadb 的符号链接。

$ ls -l /usr/bin/mysql
lrwxrwxrwx. 1 root root 7 Nov  6 06:41 /usr/bin/mysql -> mariadb