如何在 Ubuntu 20.04 上安装 MariaDB 10.5

MariaDB 是一个开源的关系数据库管理系统,向后兼容,二进制替代 MySQL。
此外,它是由 MySQL 的一些原始开发人员和社区的许多贡献者开发的。

在本教程中,我们将解释如何在 Ubuntu 20.04 上安装和保护 MariaDB 10.5.

在 Ubuntu 20.04 LTS 上安装 MariaDB 10.5

01 首先更新系统并安装software-properties-common

$sudo apt update && sudo apt upgrade
$sudo apt -y install software-properties-common

02 运行以下命令导入 Mariadb 存储库 GPG 密钥:

$sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

03 导入存储库 GPG 密钥后,通过运行以下命令添加 APT 存储库:

sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main'

04 以 root 或者具有 sudo 权限的用户身份运行以下命令,在 Ubuntu 20 上安装 MariaDB 10.5:

$sudo apt update
$sudo apt install mariadb-server mariadb-client

05 安装完成后,启动 MariaDB 服务并通过键入以下命令使其在启动时自动启动:

$systemctl enable mysql --now

06 要验证 MariaDB 服务器是否正在运行,执行:

$sudo systemctl status mysql
● mariadb.service - MariaDB 10.5.2 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: active (running) since Sat 2016-04-25 23:57:39 UTC; 2min 8s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 4309 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 2344)
     Memory: 82.5M
     CGroup: /system.slice/mariadb.service
             └─4309 /usr/sbin/mysqld

要保护 MariaDB 服务器,请查看我们之前的教程:使用 mysql_secure_installation 保护 MySQL 服务器/Mariadb

07 最后,使用mysql工具验证登录到MariaDB服务器:

$mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 56
Server version: 10.5.2-MariaDB-1:10.5.2+maria~focal-log mariadb.org binary distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
日期:2020-06-02 22:18:18 来源:oir作者:oir