AlpineLinux安装部署MariaDB
简单来说,MariaDB被视为MySQL的一个社区驱动的分支,它保留了MySQL的许多特性和功能,同时引入了一些新的特性和改进。许多用户和组织选择使用MariaDB,因为它提供了更多的自由度和对未来许可证变更的保护。而对于一些需要特定Oracle支持或特定MySQL功能的用例,依然使用MySQL是首选。
这里不对两者间的差异做任何介绍,仅介绍如何在 Alpine Linux 下安装 MariaDB。在Alpine Linux上安装MariaDB很简单,和其他的发行版本一样,使用在线仓库安装即可。
更新软件包索引:
打开终端并以root用户身份登录,更新Alpine Linux的软件包索引:
localhost:~# apk update
fetch http://mirrors.ustc.edu.cn/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.ustc.edu.cn/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
v3.20.3-159-g093e185483c [http://mirrors.ustc.edu.cn/alpine/v3.20/main]
v3.20.3-164-gfc2a8ea9609 [http://mirrors.ustc.edu.cn/alpine/v3.20/community]
OK: 24169 distinct packages available
安装MariaDB:
Alpine Linux的软件仓库中包含的是MariaDB。哪怕你执行的是apk add mysql mysql-client
,安装的也是MariaDB的服务端和客户端。下面的命令将安装MariaDB服务器和客户端工具 。
localhost:~# apk add mariadb mariadb-client
(1/12) Installing mariadb-common (10.11.8-r0)
(2/12) Installing skalibs (2.14.1.1-r0)
(3/12) Installing utmps-libs (0.1.2.2-r1)
(4/12) Installing linux-pam (1.6.0-r0)
(5/12) Installing libxml2 (2.12.7-r0)
(6/12) Installing mariadb (10.11.8-r0)
Executing mariadb-10.11.8-r0.pre-install
(7/12) Installing mariadb-openrc (10.11.8-r0)
(8/12) Installing perl (5.38.2-r0)
(9/12) Installing perl-error (0.17029-r2)
(10/12) Installing perl-git (2.45.2-r0)
(11/12) Installing git-perl (2.45.2-r0)
(12/12) Installing mariadb-client (10.11.8-r0)
Executing busybox-1.36.1-r29.trigger
OK: 777 MiB in 131 packages
初始化MySQL数据目录:
在首次启动前,需要初始化MySQL的数据库文件。这可以通过以下命令完成:
localhost:~# rc-service mariadb setup* Creating a new MySQL database ...
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OKTo start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your systemTwo all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
Af