当 MariaDB Server 的前身 MySQL 于 2009 年被 Oracle 收购时,MySQL 创始人 Michael “Monty” Widenius 出于对 Oracle 管理权的担忧而分叉了该项目,并将新项目命名为 MariaDB。 MySQL 以他的第一个女儿 My 命名,而 MariaDB 则以他的第二个女儿 Maria 命名。
在 MariaDB 5.5 之前,MariaDB Server 遵循 MySQL 版本编号模式,旨在与 MySQL 的同一主要版本兼容。
2012 年,为了反映 MySQL 中不可用的功能越来越多,MariaDB Server 的版本编号出现了分歧,MariaDB 发布了 10.0,而 MySQL 发布了 5.6。 当前的长期支持版本是 MariaDB 10.6,而最新的稳定短期支持版本是 MariaDB 10.9。
MariaDB Server 仍然保持与 MySQL 的高度兼容性,并且大多数使用 MySQL 的流行应用程序将与 MariaDB 无缝协作。
MariaDB Server 非常强调不破坏其用户的向后兼容性。 就地升级支持从旧的 MySQL 版本升级到最新的 MariaDB 版本。
MariaDB Server 提供了一种 Oracle 语法兼容模式,无需更改即可运行 Oracle 数据库应用程序。
1. 安装
1.1. 检查是否已安装 mariadb
1
dnf list installed | grep -i mariadb
2. 更新 DNF 存储库缓存
1
sudo dnf update
2.1. 安装 MariaDB
如果未安装,执行以下命令安装命令
1
sudo dnf -y install mariadb mariadb-server
说明:
这里的 -y 表示 yes, 它会自动接受所有默认选项,减少与用户交互,这在自动化脚本中非常有用。
Maria 是 mysql 的一个分支,它在 mysql 的基础上进行了改进和增强,以提供更好的性能、安全性和可靠性。 mariadb-server 是 MariaDB 的服务器软件包,它包含了 MariaDB 数据库服务器及其相关的工具、库和配置文件。 在安装 MariaDB 时,通常需要安装 mariadb-server 软件包,这样才能启动 MariaDB 服务器,并且使用 MariaDB 数据库。 因此,mariadb-server 是 MariaDB 的一个重要组成部分。
安装前可以使用 dnf search mariadb 和 dnf info mariabd 查看 rpm repo list 是否包含了 maridb 以及确认版本是否是合适
2.2. 启动 MariaDB 并设置为开机启动
1
sudo systemctl enable --now mariadb
3. 配置
3.1. 修改配置授权远程访问
1 2 3 4
sudo vi /etc/my.cnf.d/mariadb-server.cnf
bind-address = <some ip-address>
3.2. 增强 MariaDB的安全性
默认情况下,新安装的 mariadb 的密码为空,在shell终端直接输入 mysql 就能登陆数据库。
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] n ... skipping. You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure.
MariaDB [(none)]> \s -------------- mysql Ver 15.1 Distrib 10.5.22-MariaDB, for Linux (x86_64) using EditLine wrapper
Connection id: 8 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.5.22-MariaDB MariaDB Server Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 7 min 27 sec
Threads: 1 Questions: 13 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.029 --------------