MariaDB 是 MySQL 数据库的一个分支,是作为开源解决方案开发的,主要是在 GPL 许可下。 它是 MySQL 的二进制替代品,因为它与 MySQL 5.5 和更高版本共享相同的代码库。
MariaDB 数据库是 MySQL 的免费替代品,大部分增强功能专门针对数据密集型、关键业务应用程序中的高可用性、可扩展性和性能。 它可以在 GNU/Linux、FreeBSD、Solaris、Mac OS X、Windows 和许多其他操作系统上运行。
在这篇文章中,我们将看到如何在 Debian 10 上安装 MariaDB。
在 Debian 11 上安装 MariaDB 10.x
您可以通过两种方式获取 Debian 11 的 MariaDB 软件包。
- MariaDB 镜像 (MariaDB v10.6)
- Debian 存储库 (MariaDB v10.5)
从官方 MariaDB 镜像安装 MariaDB
更新存储库索引并安装所需的包。
sudo apt update sudo apt install -y software-properties-common dirmngr apt-transport-https wget
将签名密钥添加到您的系统。
wget https://mariadb.org/mariadb_release_signing_key.asc gpg --no-default-keyring --keyring ./mariadb_release_signing_key_temp.gpg --import ./mariadb_release_signing_key.asc gpg --no-default-keyring --keyring ./mariadb_release_signing_key_temp.gpg -- > ./mariadb_release_signing_key.gpg sudo mv mariadb_release_signing_key.gpg /etc/apt/trusted.gpg.d/
MariaDB 基金会为 Debian 提供了一个可以轻松安装 MariaDB 的存储库。 您可以从以下任一下载镜像中选择 MariaDB 下载页面 在您的系统上设置存储库。
使用 add-apt-repository 命令添加 MariaDB 存储库。
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://nyc2.mirrors.digitalocean.com/mariadb/repo/10.6/debian bullseye main'
使用以下命令安装 MariaDB 服务器和客户端。
sudo apt update sudo apt install -y mariadb-server mariadb-client
从 Debian 存储库安装 MariaDB
从 Debian 存储库安装 MariaDB 非常简单。 但是,它可能有一个旧版本的 MariaDB。
sudo apt update sudo apt install -y mariadb-server mariadb-client
安全的 MariaDB 安装
这 mysql_secure_installation
命令将在提供的问题的帮助下保护 MariaDB 的安装,例如 DB root 密码、管理 root 远程登录、删除匿名用户以及删除测试数据库和对其的访问。
这个命令是在 5.0.3- 版本中引入的beta 并且在配置新服务器或更改现有 MariaDB 数据库服务器时很有帮助。
sudo mysql_secure_installation
输出:
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): << No Password - Press Enter 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 << Disabling Unix Socket login and enabling password Login ... skipping. You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] Y << Change MariaDB root password New password: << Enter Password Re-enter new password: << Re-Enter Password Password updated successfully! Reloading privilege tables.. ... Success! 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 << Remove Anonymous users ... 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 << Disallow root login remotely ... 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 << Remove test database - 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 << Reload privilege ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
访问 MariaDB
登录到 MariaDB 服务器。
mysql -u root -p
需要密码
输出:
Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 53 Server version: 10.6.4-MariaDB-1:10.6.4+maria~bullseye mariadb.org binary distribution 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)]>
结论
就这样。 我希望您已经学会了如何在 Debian 11 上安装 MariaDB。此外,您可以安装 phpMyAdmin 以通过 Web 界面管理 MariaDB。