如何在 Ubuntu 22.04 LTS 上安装 MariaDB

Linux命令2年前 (2022)发布 AI观察员
149 0 0

MariaDB 是一个开源的关系数据库管理系统,通常用作 MySQL 的替代品。它是一个 MySQL 分支意味着 MariaDB 提供了类似的功能和性能指标,具有免费和完全开源的优势。如何在 Ubuntu 22.04 LTS 上安装 MariaDB

Ubuntu 22.04 LTS Jammy Jellyfish 上安装 MariaDB

apt步骤 1. 首先,通过在终端中运行以下命令,确保所有系统包都是最新的。

sudo apt update
sudo apt upgrade

步骤 2. 在 Ubuntu 22.04 上安装 MariaDB。

默认情况下,MariaDB 在 Ubuntu 22.04 基础存储库中可用。现在运行以下命令将最新版本的 MariaDB 安装到您的 Ubuntu 系统:

sudo apt install mariadb-server mariadb-client

成功安装后,启用 MariaDB(系统启动时自动启动),启动并使用以下命令验证状态:

sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadb

确认安装并检查已安装的 MariaDB 构建版本:

mariadb --version

步骤 3. 安全 MariaDB 安装。

默认情况下,MariaDB 未加固。mysql_secure_installation您可以使用脚本保护 MariaDB 。您应该仔细阅读以下每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录、删除测试数据库和访问安全 MariaDB:

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

您现在可以使用新密码连接到 MariaDB 服务器:

mysql -u root -p

输出:

Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.6.7-MariaDB-2ubuntu1 Ubuntu 22.04

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)]>

感谢您使用本教程在 Ubuntu 22.04 LTS Jammy Jellyfish 系统上安装 MariaDB 开源关系数据库。如需更多帮助或有用信息,我们建议您查看MariaDB 官方网站

© 版权声明

相关文章

天猫U特购  京东优惠购        京东优惠    天猫优惠