
图1 MariaDB
MariaDB 是一款开源的关系型数据库管理系统(RDBMS),由 MySQL 的原核心开发团队(以 Michael Widenius 为首)于 2009 年创建,旨在作为 MySQL 的社区驱动替代方案。其设计目标是在保持与 MySQL 高度兼容的基础上,通过创新功能和开源生态,提供更灵活、可靠且高性能的数据库服务。
2008 年,MySQL 被 Sun 公司收购;2009 年 Sun 又被 Oracle 收购。Oracle 对 MySQL 的商业化策略(如闭源功能、社区参与度下降)引发了原 MySQL 社区和开发者的担忧。为避免 MySQL 闭源风险并推动开源生态发展,Michael Widenius 等核心开发者基于 MySQL 代码分叉,启动了 MariaDB 项目(名称源自 Widenius 的女儿 Maria)。 目前,MariaDB 已成为全球最流行的 MySQL 替代方案之一,广泛应用于企业级场景。
MariaDB 在继承 MySQL 优点的同时,针对性能、功能和企业需求进行了优化,主要特性包括:
MariaDB 完全兼容 MySQL 的数据文件格式、API 接口、SQL 语法和命令行工具(如 mysql 客户端),现有 MySQL 应用无需修改即可直接迁移到 MariaDB。这一特性极大降低了用户的迁移成本。
MariaDB 针对查询处理、索引算法(如哈希索引、全文索引)和资源管理(内存、CPU)进行了优化,尤其在 OLTP(在线事务处理)场景下表现优异。例如:
MariaDB 采用开放治理模式,由 MariaDB 基金会(MariaDB Foundation)主导社区发展,确保技术决策的透明性和中立性。同时,商业公司(如 MariaDB Corporation)提供企业级支持、技术咨询和增值服务(如备份工具、监控平台)。
生态方面,MariaDB 兼容主流的 DevOps 工具(如 Docker、Kubernetes)、云平台(AWS、Azure、阿里云等)及中间件(如 Hibernate、Spring),并支持与 Hadoop、Spark 等大数据框架集成。
MariaDB 适用于多种场景,尤其适合以下需求:
MariaDB 凭借开源开放、高度兼容 MySQL、企业级功能丰富等优势,成为 MySQL 用户迁移或新项目选型的热门选择。无论是追求低成本迁移、高性能优化,还是需要分布式集群和高可用方案,MariaDB 都能提供灵活的支持,是当前最活跃的开源关系型数据库之一。
[root@rocky10 ~]# mkdir -p /etc/systemd/network/
[root@rocky10 ~]# touch /etc/systemd/network/70-eth0.link
[root@rocky10 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:02:55:30 brd ff:ff:ff:ff:ff:ff
altname enp3s0
altname enx000c29025530
inet 172.31.15.1/20 brd 172.31.15.255 scope global dynamic noprefixroute ens160
valid_lft 1776sec preferred_lft 1776sec
inet6 fe80::20c:29ff:fe02:5530/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@rocky10 ~]# cat > /etc/systemd/network/70-eth0.link << EOF
[Match]
MACAddress=00:0c:29:f8:60:8f
[Link]
Name=eth0
EOF
# 也可以执行下面命令
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
ETHMAC=`ip addr show ${ETHNANME} | awk -F' ' '/ether/{print $2}'`
mkdir /etc/systemd/network/
touch /etc/systemd/network/70-eth0.link
cat > /etc/systemd/network/70-eth0.link << EOF
[Match]
MACAddress=${ETHMAC}
[Link]
Name=eth0
EOF[root@rocky10 ~]# mv /etc/NetworkManager/system-connections/ens160.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection
[root@rocky10 ~]# sed -i.bak 's/'ens160'/eth0/' /etc/NetworkManager/system-connections/eth0.nmconnection
# 也可以执行下面命令
mv /etc/NetworkManager/system-connections/${ETHNAME}.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/NetworkManager/system-connections/eth0.nmconnectionnet.ifnames=0 biosdevname=0执行以下命令:
sed -ri.bak '/^GRUB_CMDLINE_LINUX=/s@"$@ net.ifnames=0 biosdevname=0"@' /etc/default/grub然后更新 GRUB 配置:
grub2-mkconfig -o /boot/grub2/grub.cfg如果是 UEFI 引导系统,更新命令为:
# Rocky
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
# Almalinux
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
# CentOS
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
# openEuler
grub2-mkconfig -o /boot/efi/EFI/openEuler/grub.cfg
# AnolisOS
grub2-mkconfig -o /boot/efi/EFI/anolis/grub.cfg
# OpenCloudOS
grub2-mkconfig -o /boot/efi/EFI/opencloudos/grub.cfg
# Kylin Server
grub2-mkconfig -o /boot/efi/EFI/kylin/grub.cfg
# UOS Server
grub2-mkconfig -o /boot/efi/EFI/uos/grub.cfg
# UEFI 引导系统可以直接执行下面命令:
EFI_DIR=`find /boot/efi/ -name "grub.cfg" | awk -F"/" '{print $5}'`
grub2-mkconfig -o /boot/efi/EFI/${EFI_DIR}/grub.cfgSUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<网卡MAC地址>", NAME="eth0"注意:创建Udev这个步骤只在AnolisOS 8上执行。
将 <网卡MAC地址> 替换为实际网卡的 MAC 地址。
[root@anolisos8 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:47:02:3f brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 172.31.15.25/20 brd 172.31.15.255 scope global dynamic noprefixroute ens33
valid_lft 1785sec preferred_lft 1785sec
inet6 fe80::20c:29ff:fe47:23f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@anolis8 ~]# cat >> /etc/udev/rules.d/10-network.rules << EOF
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:0c:29:c5:38:3b", NAME="eth0"
EOF
# 也可以执行下面命令
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
ETHMAC=`ip addr show ${ETHNANME} | awk -F' ' '/ether/{print $2}'`
cat >> /etc/udev/rules.d/10-network.rules << EOF
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="${ETHMAC}", NAME="eth0"
EOFETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
mv /etc/sysconfig/network-scripts/ifcfg-${ETHNAME} /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0# Ubuntu和Debian先启用root用户,并设置密码
raymond@ubuntu2404:~$ cat set_root_login.sh
#!/bin/bash
read -p "请输入密码: " PASSWORD
echo ${PASSWORD} |sudo -S sed -ri 's@#(PermitRootLogin )prohibit-password@\1yes@' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo -S passwd root <<-EOF
${PASSWORD}
${PASSWORD}
EOF
raymond@ubuntu2404:~$ bash set_root_login.sh
请输入密码: 123456
[sudo] password for raymond: New password: Retype new password: passwd: password updated successfullynet.ifnames=0 biosdevname=0执行以下命令:
sed -ri.bak '/^GRUB_CMDLINE_LINUX=/s@"$@net.ifnames=0 biosdevname=0"@' /etc/default/grub然后更新 GRUB 配置:
grub-mkconfig -o /boot/grub/grub.cfg如果是 UEFI 引导系统,更新命令为:
# Ubuntu
grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg
# Debian
grub-mkconfig -o /boot/efi/EFI/debian/grub.cfg
# UEFI 引导系统可以直接执行下面命令:
EFI_DIR=`find /boot/efi/ -name "grub.cfg" | awk -F"/" '{print $5}'`
grub-mkconfig -o /boot/efi/EFI/${EFI_DIR}/grub.cfg# Ubuntu Server 24.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/50-cloud-init.yaml
# Ubuntu Server 22.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
touch /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
cat > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg <<-EOF
network: {config: disabled}
EOF
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/50-cloud-init.yaml
# Ubuntu Server 20.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/00-installer-config.yaml
# Ubuntu Server 18.04 LTS
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/netplan/01-netcfg.yaml
# Debian
ETHNAME=`ip addr | awk -F"[ :]" '/^2/{print $3}'`
sed -i.bak 's/'${ETHNAME}'/eth0/' /etc/network/interfacesreboot重启后,网卡名称将变为 eth0。
1ETHNAME=`ip addr |awk -F"[ :]"'/^2/{print $3}'`
2
3# IP变量是ip地址,PREFIX变量是子网掩码位数;GATEWAY变量是网关地址;PRIMARY_DNS变量是主DNS,BACKUP_DNS变量是备用DNS,根据自己的需求修改。
4IP=172.31.0.10
5PREFIX=20
6GATEWAY=172.31.0.2
7PRIMARY_DNS=223.5.5.5
8BACKUP_DNS=180.76.76.76Rocky Linux 9/10、Almalinux 9/10、CentOS Stream 9/10、AnolisOS 23、OpenCloudOS 9:
1cat> /etc/NetworkManager/system-connections/${ETHNAME}.nmconnection <<-EOF
2[connection]
3id=${ETHNAME}
4type=ethernet
5interface-name=${ETHNAME}
6
7[ipv4]
8address1=${IP}/${PREFIX},${GATEWAY}
9dns=${PRIMARY_DNS};${BACKUP_DNS};
10method=manual
11EOFRocky Linux 8、Almalinux 8、CentOS 7、CentOS Stream 8、openEuler 22.03和24.03 LTS、AnolisOS 8、OpenCloudOS 8、Kylin Server v10/v11、UOS Server v20:
1cat> /etc/sysconfig/network-scripts/ifcfg-${ETHNAME}<<-EOF
2NAME=${ETHNAME}
3DEVICE=${ETHNAME}
4ONBOOT=yes
5BOOTPROTO=none
6TYPE=Ethernet
7IPADDR=${IP}
8PREFIX=${PREFIX}
9GATEWAY=${GATEWAY}
10DNS1=${PRIMARY_DNS}
11DNS2=${BACKUP_DNS}
12EOFUbuntu:
1# Ubuntu Server 18.04 LTS
2cat> /etc/netplan/01-netcfg.yaml <<-EOF
3network:
4 version: 2
5 renderer: networkd
6 ethernets:
7${ETHNAME}:
8 dhcp4: no
9 dhcp6: no
10 addresses: [${IP}/${PREFIX}]
11 gateway4: ${GATEWAY}
12 nameservers:
13 addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
14
15# Ubuntu Server 20.04 LTS
16cat> /etc/netplan/00-installer-config.yaml <<-EOF
17network:
18 version: 2
19 renderer: networkd
20 ethernets:
21${ETHNAME}:
22 dhcp4: no
23 dhcp6: no
24 addresses: [${IP}/${PREFIX}]
25 gateway4: ${GATEWAY}
26 nameservers:
27 addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
28EOF
29
30# Ubuntu Server 22.04/24.04 LTS
31cat> /etc/netplan/50-cloud-init.yaml <<-EOF
32network:
33 version: 2
34 renderer: networkd
35 ethernets:
36${ETHNAME}:
37 dhcp4: no
38 dhcp6: no
39 addresses: [${IP}/${PREFIX}]
40 routes:
41 - to: default
42 via: ${GATEWAY}
43 nameservers:
44 addresses: [${PRIMARY_DNS}, ${BACKUP_DNS}]
45EOFDebian:
1sed-ri-e"s/allow-hotplug/auto/g"-e"s/dhcp/static/g" /etc/network/interfaces
2sed-i'/static/a\address '${IP}'/'${PREFIX}'\ngateway '${GATEWAY}'\ndns-nameservers '${PRIMARY_DNS}' '${BACKUP_DNS}'\n' /etc/network/interfacesopenSUSE:
1cat> /etc/sysconfig/network/ifcfg-${ETHNAME}<<-EOF
2STARTMODE='auto'
3BOOTPROTO='static'
4IPADDR='${IP}/${PREFIX}'
5EOF
6touch /etc/sysconfig/network/routes
7cat> /etc/sysconfig/network/routes <<-EOF
8default ${GATEWAY} - -
9EOF
10sed-ri's/(NETCONFIG_DNS_STATIC_SERVERS=).*/\1"'${PRIMARY_DNS}' '${BACKUP_DNS}'"/g' /etc/sysconfig/network/configRocky:
1# 阿里云镜像站Rocky系统镜像源地址是:mirrors.aliyun.com/rockylinux,火山引擎镜像站Rocky系统镜像源地址是:mirrors.volces.com/rockylinux,后面地址是rockylinux,使用下面命令执行
2MIRROR=mirrors.aliyun.com
3sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://'${MIRROR}'/rockylinux|g' /etc/yum.repos.d/[Rr]ocky*.repo
4
5# 搜狐镜像站Rocky系统镜像源地址是:mirrors.sohu.com/Rocky,后面地址是Rocky,使用下面命令执行
6MIRROR=mirrors.sohu.com
7sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^#baseurl=http://'${OLD_MIRROR}'/$contentdir|baseurl=https://'${MIRROR}'/Rocky|g' /etc/yum.repos.d/[Rr]ocky*.repo
8
9# 其余镜像站Rocky系统镜像源地址后面地址都是rocky,使用下面命令执行
10MIRROR=mirrors.tencent.com
11sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://'${MIRROR}'/rocky|g' /etc/yum.repos.d/[Rr]ocky*.repo
12
13dnf clean all && dnf makecacheAlmalinux:
1MIRROR=mirrors.tencent.com
2OLD_MIRROR=$(sed-rn'/^.*baseurl=/s@.*=http.*://(.*)/(.*)/\$releasever/.*/$@\1@p' /etc/yum.repos.d/almalinux*.repo |head-1)
3sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^# baseurl=https://'${OLD_MIRROR}'|baseurl=https://'${MIRROR}'|g' /etc/yum.repos.d/almalinux*.repoCentOS Stream 9和10:
1cat update_mirror.pl
2#!/usr/bin/perl
3
4use strict;
5use warnings;
6use autodie;
7
8# 要修改镜像源,请去修改url变量!
9my $url='mirrors.aliyun.com';
10my $mirrors="https://$url/centos-stream";
11
12if(@ARGV <1){
13 die "Usage: $0...\n";
14}
15
16while(my $filename=shift @ARGV){
17 my $backup_filename=$filename.'.bak';
18rename$filename, $backup_filename;
19
20open my $input, "<", $backup_filename;
21open my $output, ">", $filename;
22
23while(<$input>){
24 s/^metalink/# metalink/;
25
26if(m/^name/){
27 my (undef, $repo, $arch)=split /-/;
28$repo=~ s/^\s+|\s+$//g;
29($arch= defined $arch ? lc($arch):'')=~ s/^\s+|\s+$//g;
30
31if($repo=~ /^Extras/){
32$_ .="baseurl=${mirrors}/SIGs/\$releasever-stream/extras".($arch eq 'source' ? "/${arch}/":"/\$basearch/")."extras-common\n";
33}else{
34$_ .="baseurl=${mirrors}/\$releasever-stream/$repo".($arch eq 'source' ? "/":"/\$basearch/").($arch ne '' ? "${arch}/tree/":"os")."\n";
35}
36}
37
38 print $output$_;
39}
40}
41
42rpm-q perl &> /dev/null ||{echo-e"\\033[01;31m "安装perl工具,请稍等..."\033[0m";yum -yinstall perl ;}
43
44perl ./update_mirror.pl /etc/yum.repos.d/centos*.repo
45
46dnf clean all && dnf makecacheCentOS Stream 8:
1MIRROR=mirrors.aliyun.com
2sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://'${MIRROR}'/centos-vault|g' /etc/yum.repos.d/CentOS-*.repo
3
4dnf clean all && dnf makecacheCentOS 7:
1MIRROR=mirrors.aliyun.com
2OS_RELEASE_FULL_VERSION=`cat /etc/centos-release |sed-rn's/^(CentOS Linux release )(.*)( \(Core\))/\2/p'`
3sed-i.bak-e's|^mirrorlist=|#mirrorlist=|g'-e's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://'${MIRROR}'/centos-vault|g'-e"s/\$releasever/${OS_RELEASE_FULL_VERSION}/g" /etc/yum.repos.d/CentOS-*.repo
4
5yum clean all && yum makecacheUbuntu Server 24.04 LTS:
1MIRROR=mirrors.aliyun.com
2sed-ri"s@^(URIs: )(http.*://)(.*)(/ubuntu).?@\1https://${MIRROR}\4@g" /etc/apt/sources.list.d/ubuntu.sources
3
4apt updateUbuntu Server 18.04/20.04/22.04 LTS:
1MIRROR=mirrors.aliyun.com
2OLD_MIRROR=`sed-rn"s@^deb http(.*)://(.*)/ubuntu/? $(lsb_release -cs) main.*@\2@p" /etc/apt/sources.list`
3SECURITY_MIRROR=`sed-rn"s@^deb http(.*)://(.*)/ubuntu.* $(lsb_release -cs)-security main.*@\2@p" /etc/apt/sources.list`
4sed-i.bak-e's@http.*://'${OLD_MIRROR}'@https://'${MIRROR}'@g'-e's@http.*://'${SECURITY_MIRROR}'@https://'${MIRROR}'@g' /etc/apt/sources.list
5
6apt updateDebian:
1MIRROR=mirrors.aliyun.com
2OLD_MIRROR=`sed-rn"s@^deb http(.*)://(.*)/debian/? $(lsb_release -cs) main.*@\2@p" /etc/apt/sources.list`
3SECURITY_MIRROR=`sed-rn"s@^deb http(.*)://(.*)/debian-security $(lsb_release -cs)-security main.*@\2@p" /etc/apt/sources.list`
4sed-ri.bak-e's/'${OLD_MIRROR}'/'${MIRROR}'/g'-e's/'${SECURITY_MIRROR}'/'${MIRROR}'/g'-e's/^(deb cdrom.*)/#\1/g' /etc/apt/sources.list
5
6apt updateopenEuler:
1MIRROR=mirrors.aliyun.com
2OLD_MIRROR=$(awk -F'/''/^baseurl=/{print $3}' /etc/yum.repos.d/openEuler.repo |head-1)
3sed-i.bak-e's|^metalink=|#metalink=|g'-e's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'/openeuler|g' /etc/yum.repos.d/openEuler.repo
4
5dnf clean all && dnf makecacheAnolisOS:
1OLD_MIRROR=$(sed-rn'/^.*baseurl=/s@.*=http.*://(.*)/(.*)/\$releasever/.*/$@\1@p' /etc/yum.repos.d/AnolisOS*.repo |head-1)
2
3# 中国科学院软件研究所镜像站AnolisOS系统镜像源地址是:mirror.iscas.ac.cn/openanolis,后面地址是openanolis,使用下面命令执行
4MIRROR=mirror.iscas.ac.cn
5sed-i.bak-e's|http.*://'${OLD_MIRROR}'/anolis|https://'${MIRROR}'/openanolis|g' /etc/yum.repos.d/AnolisOS*.repo
6
7# 其余镜像站AnolisOS系统镜像源地址后面地址都是anolis,使用下面命令执行
8MIRROR=mirrors.aliyun.com
9sed-i.bak-e's|http.*://'${OLD_MIRROR}'/anolis|https://'${MIRROR}'/anolis|g' /etc/yum.repos.d/AnolisOS*.repo
10
11dnf clean all && dnf makecacheOpenCloudOS:
1MIRROR=mirrors.tencent.com
2OLD_MIRROR=$(awk -F'/''/^baseurl=/{print $3}' /etc/yum.repos.d/OpenCloudOS*.repo |head-1)
3sed-i.bak-e's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'|g' /etc/yum.repos.d/OpenCloudOS*.repo
4
5dnf clean all && dnf makecacheopenSUSE:
1MIRROR=mirrors.aliyun.com
2OLD_MIRROR=$(awk -F'/''/^baseurl=/{print $3}' /etc/zypp/repos.d/repo-*.repo |head-1)
3sed-i.bak's|http.*://'${OLD_MIRROR}'|https://'${MIRROR}'/opensuse|g' /etc/zypp/repos.d/repo-*.repo
4
5zypper clean &&zypper refresh1# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、openSUSE、Kylin Server、UOS Server
2systemctl disable --now firewalld
3
4# CentOS 7还要执行下面命令
5systemctl disable --now NetworkManager
6
7# Ubuntu
8systemctl disable --now ufw
9
10# Debian默认没有安装防火墙,不用设置1# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、UOS Server
2setenforce 0
3sed-i's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
4
5# Ubuntu、Debian和openSUSE默认没有安装SELinux,不用设置1# openSUSE发行版默认不启用SELinux,而是使用AppArmor来提供强制访问控制(MAC)功能,需要禁用AppArmor。
2systemctl disable --now apparmor1timedatectl set-timezone Asia/Shanghai
2echo'Asia/Shanghai'>/etc/timezone
3
4# Ubuntu还要设置下面内容
5cat>> /etc/default/locale <<-EOF
6LC_TIME=en_DK.UTF-8
7EOF在Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、Kylin Server、UOS Server上安装MariaDB:
1[root@rocky10 ~]# yum list mariadb-server --showduplicates
2Last metadata expiration check: 0:08:25 ago on Fri 08 Aug 2025 01:13:14 PM CST.
3Available Packages
4mariadb-server.x86_64 3:10.11.11-1.el10 appstream
5
6[root@rocky10 ~]# yum -y install mariadb-server
7
8[root@rocky10 ~]# systemctl enable --now mariadb
9
10[root@rocky10 ~]# ls /var/lib/mysql
11aria_log.00000001 ddl_recovery.log ibdata1 ibtmp1 mysql mysql_upgrade_info sys
12aria_log_control ib_buffer_pool ib_logfile0 multi-master.info mysql.sock performance_schema
13
14[root@rocky10 ~]# mariadb -V
15mariadb Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper
16
17[root@rocky10 ~]# systemctl status mariadb
18● mariadb.service - MariaDB 10.11 database server
19 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
20 Active: active (running) since Fri 2025-08-08 13:28:01 CST; 1min 11s ago
21 Invocation: 3d54eb415ece4dcebce26a9b4e05034e
22 Docs: man:mariadbd(8)
23 https://mariadb.com/kb/en/library/systemd/
24 Process: 1619ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
25 Process: 1642ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCES>
26 Process: 1750ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
27 Main PID: 1737(mariadbd)
28 Status: "Taking your SQL requests now..."
29 Tasks: 8(limit: 10481)
30 Memory: 206.2M (peak: 231.3M)
31 CPU: 889ms
32 CGroup: /system.slice/mariadb.service
33 └─1737 /usr/libexec/mariadbd --basedir=/usr
34
35Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: you need to be the system 'mysql' user to connect.
36Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: After connecting you can set the password, if you would ne>
37Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: able to connect as any of these users with a password and >
38Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: See the MariaDB Knowledgebase at https://mariadb.com/kb
39Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: Please report any problems at https://mariadb.org/jira
40Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: The latest information about MariaDB is available at https>
41Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: Consider joining MariaDB's strong and vibrant community:
42Aug 08 13:28:01 rocky10 mariadb-prepare-db-dir[1681]: https://mariadb.org/get-involved/
43Aug 08 13:28:01 rocky10 (mariadbd)[1737]: mariadb.service: Referenced but unset environment variable evaluates t>
44Aug 08 13:28:01 rocky10 systemd[1]: Started mariadb.service - MariaDB 10.11 database server.
45
46[root@rocky10 ~]# mariadb
47Welcome to the MariaDB monitor. Commands end with ; or \g.
48Your MariaDB connection id is 3
49Server version: 10.11.11-MariaDB MariaDB Server
50
51Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
52
53Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
54
55MariaDB [(none)]> status
56--------------
57mysql Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper
58
59Connection id: 3
60Current database:
61Current user: root@localhost
62SSL: Not in use
63Current pager: stdout
64Using outfile: ''
65Using delimiter: ;
66Server: MariaDB
67Server version: 10.11.11-MariaDB MariaDB Server
68Protocol version: 10
69Connection: Localhost via UNIX socket
70Server characterset: latin1
71Db characterset: latin1
72Client characterset: utf8mb3
73Conn. characterset: utf8mb3
74UNIX socket: /var/lib/mysql/mysql.sock
75Uptime: 1 min 44 sec
76
77Threads: 1 Questions: 4 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.038
78--------------
79
80MariaDB [(none)]> show databases;
81+--------------------+
82| Database |
83+--------------------+
84| information_schema |
85| mysql |
86| performance_schema |
87| sys |
88+--------------------+
894 rows inset(0.001 sec)
90
91MariaDB [(none)]>exit
92Bye在Ubuntu和Debian上安装MariaDB:
1root@ubuntu2404:~# apt-cache madison mariadb-server
2mariadb-server |1:10.11.13-0ubuntu0.24.04.1 | https://mirrors.aliyun.com/ubuntu noble-updates/universe amd64 Packages
3mariadb-server |1:10.11.13-0ubuntu0.24.04.1 | https://mirrors.aliyun.com/ubuntu noble-security/universe amd64 Packages
4mariadb-server |1:10.11.7-2ubuntu2 | https://mirrors.aliyun.com/ubuntu noble/universe amd64 Packages
5
6root@ubuntu2404:~# apt -y install mariadb-server
7
8root@ubuntu2404:~# systemctl enable --now mariadb
9
10root@ubuntu2404:~# ls /var/lib/mysql
11aria_log.00000001 ddl_recovery.log ib_buffer_pool ib_logfile0 multi-master.info mysql_upgrade_info sys
12aria_log_control debian-10.11.flag ibdata1 ibtmp1 mysql performance_schema
13
14root@ubuntu2404:~# mariadb -V
15mysql Ver 15.1 Distrib 10.11.13-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
16
17root@ubuntu2404:~# systemctl status mariadb
18● mariadb.service - MariaDB 10.11.13 database server
19 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
20 Active: active (running) since Fri 2025-08-08 15:43:17 CST; 3min 43s ago
21 Docs: man:mariadbd(8)
22 https://mariadb.com/kb/en/library/systemd/
23 Main PID: 1949(mariadbd)
24 Status: "Taking your SQL requests now..."
25 Tasks: 10(limit: 14588)
26 Memory: 78.9M (peak: 82.0M)
27 CPU: 554ms
28 CGroup: /system.slice/mariadb.service
29 └─1949 /usr/sbin/mariadbd
30
31Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] InnoDB: log sequence number 45502; trans>
32Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] Plugin 'FEEDBACK' is disabled.
33Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] InnoDB: Loading buffer pool(s) from /var>
34Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Warning] You need to use --log-bin to make --e>
35Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] Server socket created on IP: '127.0.0.1'.
36Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] InnoDB: Buffer pool(s) load completed at>
37Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: 2025-08-08 15:43:17 0[Note] /usr/sbin/mariadbd: ready for connection>
38Aug 08 15:43:17 ubuntu2404 mariadbd[1949]: Version: '10.11.13-MariaDB-0ubuntu0.24.04.1' socket: '/run/mysqld/my>
39Aug 08 15:43:17 ubuntu2404 systemd[1]: Started mariadb.service - MariaDB 10.11.13 database server.
40Aug 08 15:43:17 ubuntu2404 /etc/mysql/debian-start[1967]: Upgrading MariaDB tables if necessary.
41
42root@ubuntu2404:~# mariadb
43Welcome to the MariaDB monitor. Commands end with ; or \g.
44Your MariaDB connection id is 31
45Server version: 10.11.13-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04
46
47Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
48
49Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
50
51MariaDB [(none)]> status
52--------------
53mysql Ver 15.1 Distrib 10.11.13-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
54
55Connection id: 31
56Current database:
57Current user: root@localhost
58SSL: Not in use
59Current pager: stdout
60Using outfile: ''
61Using delimiter: ;
62Server: MariaDB
63Server version: 10.11.13-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04
64Protocol version: 10
65Connection: Localhost via UNIX socket
66Server characterset: utf8mb4
67Db characterset: utf8mb4
68Client characterset: utf8mb3
69Conn. characterset: utf8mb3
70UNIX socket: /run/mysqld/mysqld.sock
71Uptime: 4 min 13 sec
72
73Threads: 1 Questions: 61 Slow queries: 0 Opens: 33 Open tables: 26 Queries per second avg: 0.241
74--------------
75
76MariaDB [(none)]> show databases;
77+--------------------+
78| Database |
79+--------------------+
80| information_schema |
81| mysql |
82| performance_schema |
83| sys |
84+--------------------+
854 rows inset(0.000 sec)
86
87MariaDB [(none)]>exit
88Bye在openSUSE上安装MariaDB:
1opensuse15:~ # zypper search "mariadb"
2Loading repository data...
3Reading installed packages...
4
5S | Name | Summary | Type
6--+--------------------------+---------------------------------------------------------------------+-----------
7| libmariadb-devel | Development files for the MariaDB Connector C API | package
8| libmariadb3 | MariaDB connector in C | package
9| libmariadb3-32bit | MariaDB connector in C | package
10| libmariadb_plugins | Plugins for the MariaDB C Connector | package
11| libmariadbd-devel | MariaDB embedded server development files | package
12| libmariadbd19 | MariaDB embedded server library | package
13| libmariadbd104-devel | MariaDB embedded server development files | package
14| libmariadbprivate | Additional internal libraries for the MariaDB C Connector | package
15| mariadb | Server part of MariaDB | package
16| mariadb | Server part of MariaDB | srcpackage
17| mariadb-bench | Benchmarks for MariaDB | package
18| mariadb-client | Client for MariaDB | package
19| mariadb-connector-odbc | MariaDB ODBC Connector | package
20| mariadb-errormessages | The error messages files required by server, client and libmariadbd | package
21| mariadb-galera | The configuration files and scripts for galera replication | package
22| mariadb-rpm-macros | MariaDB RPM macros | package
23| mariadb-test | Testsuite for MariaDB | package
24| mariadb-tools | MariaDB tools | package
25| mariadb104 | Server part of MariaDB | srcpackage
26| mariadb104 | Server part of MariaDB | package
27| mariadb104-bench | Benchmarks for MariaDB | package
28| mariadb104-client | Client for MariaDB | package
29| mariadb104-errormessages | The error messages files required by server, client and libmariadbd | package
30| mariadb104-galera | The configuration files and scripts for galera replication | package
31| mariadb104-rpm-macros | MariaDB RPM macros | package
32| mariadb104-test | Testsuite for MariaDB | package
33| mariadb104-tools | MariaDB tools | package
34
35opensuse15:~ # zypper info mariadb
36Loading repository data...
37Reading installed packages...
38
39
40Information for package mariadb:
41--------------------------------
42Repository : Update repository with updates from SUSE Linux Enterprise 15
43Name : mariadb
44Version :10.11.11-150600.4.10.1
45Arch : x86_64
46Vendor : SUSE LLC <https://www.suse.com/>
47Installed Size :158.8 MiB
48Installed : No
49Status : not installed
50Source package : mariadb-10.11.11-150600.4.10.1.src
51Upstream URL : https://www.mariadb.org
52Summary : Server part of MariaDB
53Description :
54 MariaDB is an open-source, multi-threaded, relational database management
55 system. It's a backward compatible, drop-in replacement branch of the
56 MySQL Community Server.
57
58 This package only contains the server-side programs.
59
60opensuse15:~ # zypper install -y mariadb
61
62opensuse15:~ # systemctl enable --now mariadb
63
64opensuse15:~ # ls /var/lib/mysql
65aria_log.00000001 ib_buffer_pool ibtmp1 mysql_upgrade_info sys
66aria_log_control ib_logfile0 multi-master.info opensuse15.pid test
67ddl_recovery.log ibdata1 mysql performance_schema
68
69opensuse15:~ # mariadb -V
70mariadb Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper
71
72opensuse15:~ # systemctl status mariadb
73● mariadb.service - MariaDB database server
74 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
75 Active: active (running) since Sun 2025-08-17 14:25:20 CST; 43s ago
76 Docs: man:mysqld(8)
77 https://mariadb.com/kb/en/library/systemd/
78 Process: 13918ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install(code=exited, status=0/SUCCESS)
79 Process: 13968ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS)
80 Main PID: 13975(mysqld)
81 Status: "Taking your SQL requests now..."
82 Tasks: 10(limit: 2250)
83 CPU: 1.067s
84 CGroup: /system.slice/mariadb.service
85 └─13975 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql --socket=/run/mysql/mysql.sock
86
87Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: The second is mysql@localhost, it has no password either>
88Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: you need to be the system 'mysql' user to connect.
89Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: After connecting you can set the password, if you would >
90Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: able to connect as any of these users with a password an>
91Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: See the MariaDB Knowledgebase at https://mariadb.com/kb
92Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: Please report any problems at https://mariadb.org/jira
93Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: The latest information about MariaDB is available at htt>
94Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: Consider joining MariaDB's strong and vibrant community:
95Aug 1714:25:19 opensuse15 mysql-systemd-helper[13924]: https://mariadb.org/get-involved/
96Aug 1714:25:20 opensuse15 systemd[1]: Started MariaDB database server.
97
98opensuse15:~ # mariadb
99Welcome to the MariaDB monitor. Commands end with ; or \g.
100Your MariaDB connection id is 3
101Server version: 10.11.11-MariaDB MariaDB package
102
103Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
104
105Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
106
107MariaDB [(none)]> status
108--------------
109mariadb Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper
110
111Connection id: 3
112Current database:
113Current user: root@localhost
114SSL: Not in use
115Current pager: less
116Using outfile: ''
117Using delimiter: ;
118Server: MariaDB
119Server version: 10.11.11-MariaDB MariaDB package
120Protocol version: 10
121Connection: Localhost via UNIX socket
122Server characterset: utf8mb4
123Db characterset: utf8mb4
124Client characterset: utf8mb3
125Conn. characterset: utf8mb3
126UNIX socket: /run/mysql/mysql.sock
127Uptime: 1 min 7 sec
128
129Threads: 1 Questions: 4 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.059
130--------------
131
132MariaDB [(none)]> show databases;
133+--------------------+
134| Database |
135+--------------------+
136| information_schema |
137| mysql |
138| performance_schema |
139| sys |
140|test|# 有test数据库
141+--------------------+
1425 rows inset(0.000 sec)
143
144MariaDB [(none)]>select user,host from mysql.user;
145+-------------+------------+
146| User | Host |
147+-------------+------------+
148| PUBLIC ||
149|| localhost |# 有匿名用户
150| mariadb.sys | localhost |
151| mysql | localhost |
152| root | localhost |
153|| opensuse15 |# 有远程登录用户
154+-------------+------------+
1556 rows inset(0.001 sec)
156
157MariaDB [(none)]>exit
158Bye
159
160# 有test数据库、匿名用户和远程登录用户,需要安全初始化
161opensuse15:~ # mariadb-secure-installation
162
163NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
164 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
165
166In order to log into MariaDB to secure it, we'll need the current
167password for the root user. If you've just installed MariaDB, and
168haven't set the root password yet, you should just press enter here.
169
170Enter current password for root (enter for none): # 输入 root 的当前密码(不输入),直接敲回车
171OK, successfully used password, moving on...
172
173Setting the root password or using the unix_socket ensures that nobody
174can log into the MariaDB root user without the proper authorisation.
175
176You already have your root account protected, so you can safely answer 'n'.
177
178Switch to unix_socket authentication [Y/n] y # 输入y,切换到 unix_socket 身份验证
179Enabled successfully!
180Reloading privilege tables..
181... Success!
182
183
184You already have your root account protected, so you can safely answer 'n'.
185
186Change the root password? [Y/n] n # 输入n,不设置root密码
187... skipping.
188
189By default, a MariaDB installation has an anonymous user, allowing anyone
190to log into MariaDB without having to have a user account created for
191them. This is intended only for testing, and to make the installation
192go a bit smoother. You should remove them before moving into a
193production environment.
194
195Remove anonymous users? [Y/n] y # 输入y,移除匿名账户
196... Success!
197
198Normally, root should only be allowed to connect from 'localhost'. This
199ensures that someone cannot guess at the root password from the network.
200
201Disallow root login remotely? [Y/n] y # 输入y,禁止 root 远程登录
202... Success!
203
204By default, MariaDB comes with a database named 'test' that anyone can
205access. This is also intended only for testing, and should be removed
206before moving into a production environment.
207
208Remove test database and access to it? [Y/n] y # 输入y,移除测试库
209 - Dropping test database...
210... Success!
211 - Removing privileges on test database...
212... Success!
213
214Reloading the privilege tables will ensure that all changes made so far
215will take effect immediately.
216
217Reload privilege tables now? [Y/n] y # 输入y,重新加载权限表
218... Success!
219
220Cleaning up...
221
222All done! If you've completed all of the above steps, your MariaDB
223installation should now be secure.
224
225Thanks for using MariaDB!
226
227opensuse15:~ # mariadb
228Welcome to the MariaDB monitor. Commands end with ; or \g.
229Your MariaDB connection id is 14
230Server version: 10.11.11-MariaDB MariaDB package
231
232Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
233
234Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
235
236MariaDB [(none)]> status
237--------------
238mariadb Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper
239
240Connection id: 14
241Current database:
242Current user: root@localhost
243SSL: Not in use
244Current pager: less
245Using outfile: ''
246Using delimiter: ;
247Server: MariaDB
248Server version: 10.11.11-MariaDB MariaDB package
249Protocol version: 10
250Connection: Localhost via UNIX socket
251Server characterset: utf8mb4
252Db characterset: utf8mb4
253Client characterset: utf8mb3
254Conn. characterset: utf8mb3
255UNIX socket: /run/mysql/mysql.sock
256Uptime: 2 min 34 sec
257
258Threads: 1 Questions: 30 Slow queries: 0 Opens: 21 Open tables: 14 Queries per second avg: 0.194
259--------------
260
261MariaDB [(none)]> show databases;
262+--------------------+
263| Database |
264+--------------------+
265| information_schema |
266| mysql |
267| performance_schema |
268| sys |
269+--------------------+
2704 rows inset(0.000 sec)
271# 没有test数据库
272
273MariaDB [(none)]>select user,host from mysql.user;
274+-------------+-----------+
275| User | Host |
276+-------------+-----------+
277| PUBLIC ||
278| mariadb.sys | localhost |
279| mysql | localhost |
280| root | localhost |
281+-------------+-----------+
2824 rows inset(0.001 sec)
283# 没有匿名用户和远程登录用户
284
285MariaDB [(none)]>exit
286Bye添加官方资源库,去“https://mariadb.org”网站下载,选择“Download”。

图2 MariaDB首页
在打开的网页,在“MariaDB Server Repositories”下面选择“Choose a distribution为:Red Hat Enterprise Linux 9”,选择“Choose a MariaDB Server version为:11.8”,选择“Mirror为:清华大学 TUNA 协会 (Tsinghua University TUNA Association)”,然后根据下面提示操作。

图3 MariaDB添加资源库
[root@rocky9 ~]# cat > /etc/yum.repos.d/MariaDB.repo <
2# MariaDB 11.8 RedHatEnterpriseLinux repository list - created 2025-08-17 02:34 UTC
3# https://mariadb.org/download/
4[mariadb]
5name = MariaDB
6# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
7# baseurl = https://rpm.mariadb.org/11.8/rhel/$releasever/$basearch
8baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/11.8/rhel/\$releasever/\$basearch
9# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
10gpgkey = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
11gpgcheck =1
12EOF
13
14[root@rocky9 ~]# dnf install -y MariaDB-server
15
16[root@rocky9 ~]# systemctl enable --now mariadb
17
18[root@rocky9 ~]# ls /var/lib/mysql/
19aria_log.00000001 ib_buffer_pool ibtmp1 mysql rocky9.pid test undo003
20aria_log_control ibdata1 mariadb_upgrade_info mysql.sock sys undo001
21ddl_recovery.log ib_logfile0 multi-master.info performance_schema tc.log undo002
22
23[root@rocky9 ~]# mariadb -V
24mariadb from 11.8.3-MariaDB, client 15.2for Linux (x86_64) using EditLine wrapper
25
26[root@rocky9 ~]# systemctl status mariadb
27● mariadb.service - MariaDB 11.8.3 database server
28 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
29 Drop-In: /etc/systemd/system/mariadb.service.d
30 └─migrated-from-my.cnf-settings.conf
31 Active: active (running) since Sun 2025-08-17 10:36:26 CST; 1min 17s ago
32 Docs: man:mariadbd(8)
33 https://mariadb.com/kb/en/library/systemd/
34 Process: 12291ExecStartPre=/bin/sh -c[!-e /usr/bin/galera_recovery ]&&VAR=||VAR=`/usr/bin/galera_r>
35 Process: 12308ExecStartPost=/bin/rm -f /var/lib/mysql/wsrep-start-position (code=exited, status=0/SUCCESS)
36 Main PID: 12298(mariadbd)
37 Status: "Taking your SQL requests now..."
38 Tasks: 8(limit: 13443)
39 Memory: 126.7M
40 CPU: 563ms
41 CGroup: /system.slice/mariadb.service
42 └─12298 /usr/sbin/mariadbd
43
44Aug 1710:36:25 rocky9 mariadbd[12298]: 2025-08-17 10:36:25 0[Note] InnoDB: Loading buffer pool(s) from /var/li>
45Aug 1710:36:25 rocky9 mariadbd[12298]: 2025-08-17 10:36:25 0[Note] Plugin 'FEEDBACK' is disabled.
46Aug 1710:36:25 rocky9 mariadbd[12298]: 2025-08-17 10:36:25 0[Note] Plugin 'wsrep-provider' is disabled.
47Aug 1710:36:25 rocky9 mariadbd[12298]: 2025-08-17 10:36:25 0[Note] InnoDB: Buffer pool(s) load completed at 25>
48Aug 1710:36:26 rocky9 mariadbd[12298]: 2025-08-17 10:36:26 0[Note] Server socket created on IP: '0.0.0.0', por>
49Aug 1710:36:26 rocky9 mariadbd[12298]: 2025-08-17 10:36:26 0[Note] Server socket created on IP: '::', port: '3>
50Aug 1710:36:26 rocky9 mariadbd[12298]: 2025-08-17 10:36:26 0[Note] mariadbd: Event Scheduler: Loaded 0 events
51Aug 1710:36:26 rocky9 mariadbd[12298]: 2025-08-17 10:36:26 0[Note] /usr/sbin/mariadbd: ready for connections.
52Aug 1710:36:26 rocky9 mariadbd[12298]: Version: '11.8.3-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 33>
53Aug 1710:36:26 rocky9 systemd[1]: Started MariaDB 11.8.3 database server.
54
55[root@rocky9 ~]# mariadb
56mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
57Welcome to the MariaDB monitor. Commands end with ; or \g.
58Your MariaDB connection id is 3
59Server version: 11.8.3-MariaDB MariaDB Server
60
61Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
62
63Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
64
65MariaDB [(none)]> status
66--------------
67mysql from 11.8.3-MariaDB, client 15.2for Linux (x86_64) using EditLine wrapper
68
69Connection id: 3
70Current database:
71Current user: root@localhost
72SSL: Cipher in use is TLS_AES_256_GCM_SHA384, cert is OK
73Current pager: stdout
74Using outfile: ''
75Using delimiter: ;
76Server: MariaDB
77Server version: 11.8.3-MariaDB MariaDB Server
78Protocol version: 10
79Connection: Localhost via UNIX socket
80Server characterset: utf8mb4
81Db characterset: utf8mb4
82Client characterset: utf8mb4
83Conn. characterset: utf8mb4
84UNIX socket: /var/lib/mysql/mysql.sock
85Uptime: 1 min 45 sec
86
87Threads: 1 Questions: 4 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.038
88--------------
89
90MariaDB [(none)]> show databases;
91+--------------------+
92| Database |
93+--------------------+
94| information_schema |
95| mysql |
96| performance_schema |
97| sys |
98|test|# 有test数据库
99+--------------------+
1005 rows inset(0.001 sec)
101
102MariaDB [(none)]>select user,host from mysql.user;
103+-------------+-----------+
104| User | Host |
105+-------------+-----------+
106| PUBLIC ||
107|| localhost |# 有匿名用户
108| mariadb.sys | localhost |
109| mysql | localhost |
110| root | localhost |
111|| rocky9 |# 有远程登录用户
112+-------------+-----------+
1136 rows inset(0.001 sec)
114
115MariaDB [(none)]>exit
116Bye
117
118# 有test数据库、匿名用户和远程登录用户,需要安全初始化
119[root@rocky9 ~]# mariadb-secure-installation
120
121NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
122 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
123
124In order to log into MariaDB to secure it, we'll need the current
125password for the root user. If you've just installed MariaDB, and
126haven't set the root password yet, you should just press enter here.
127
128Enter current password for root (enter for none): # 输入 root 的当前密码(不输入),直接敲回车
129OK, successfully used password, moving on...
130
131Setting the root password or using the unix_socket ensures that nobody
132can log into the MariaDB root user without the proper authorisation.
133
134You already have your root account protected, so you can safely answer 'n'.
135
136Switch to unix_socket authentication [Y/n] y # 输入y,切换到 unix_socket 身份验证
137Enabled successfully!
138Reloading privilege tables..
139... Success!
140
141
142You already have your root account protected, so you can safely answer 'n'.
143
144Change the root password? [Y/n] n # 输入n,不设置root密码
145... skipping.
146
147By default, a MariaDB installation has an anonymous user, allowing anyone
148to log into MariaDB without having to have a user account created for
149them. This is intended only for testing, and to make the installation
150go a bit smoother. You should remove them before moving into a
151production environment.
152
153Remove anonymous users? [Y/n] y # 输入y,移除匿名账户
154... Success!
155
156Normally, root should only be allowed to connect from 'localhost'. This
157ensures that someone cannot guess at the root password from the network.
158
159Disallow root login remotely? [Y/n] y # 输入y,禁止 root 远程登录
160... Success!
161
162By default, MariaDB comes with a database named 'test' that anyone can
163access. This is also intended only for testing, and should be removed
164before moving into a production environment.
165
166Remove test database and access to it? [Y/n] y # 输入y,移除测试库
167 - Dropping test database...
168... Success!
169 - Removing privileges on test database...
170... Success!
171
172Reloading the privilege tables will ensure that all changes made so far
173will take effect immediately.
174
175Reload privilege tables now? [Y/n] y # 输入y,重新加载权限表
176... Success!
177
178Cleaning up...
179
180All done! If you've completed all of the above steps, your MariaDB
181installation should now be secure.
182
183Thanks for using MariaDB!
184
185[root@rocky9 ~]# mariadb
186Welcome to the MariaDB monitor. Commands end with ; or \g.
187Your MariaDB connection id is 14
188Server version: 11.8.3-MariaDB MariaDB Server
189
190Copyright (c)2000, 2018, Oracle, MariaDB Corporation Ab and others.
191
192Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
193
194MariaDB [(none)]> status
195--------------
196mariadb from 11.8.3-MariaDB, client 15.2for Linux (x86_64) using EditLine wrapper
197
198Connection id: 14
199Current database:
200Current user: root@localhost
201SSL: Cipher in use is TLS_AES_256_GCM_SHA384, cert is OK
202Current pager: stdout
203Using outfile: ''
204Using delimiter: ;
205Server: MariaDB
206Server version: 11.8.3-MariaDB MariaDB Server
207Protocol version: 10
208Connection: Localhost via UNIX socket
209Server characterset: utf8mb4
210Db characterset: utf8mb4
211Client characterset: utf8mb4
212Conn. characterset: utf8mb4
213UNIX socket: /var/lib/mysql/mysql.sock
214Uptime: 7 min 59 sec
215
216Threads: 1 Questions: 30 Slow queries: 0 Opens: 18 Open tables: 11 Queries per second avg: 0.062
217--------------
218
219MariaDB [(none)]> show databases;
220+--------------------+
221| Database |
222+--------------------+
223| information_schema |
224| mysql |
225| performance_schema |
226| sys |
227+--------------------+
2284 rows inset(0.001 sec)
229# 没有test数据库
230
231MariaDB [(none)]>select user,host from mysql.user;
232+-------------+-----------+
233| User | Host |
234+-------------+-----------+
235| PUBLIC ||
236| mariadb.sys | localhost |
237| mysql | localhost |
238| root | localhost |
239+-------------+-----------+
2404 rows inset(0.001 sec)
241# 没有匿名用户和远程登录用户
242
243MariaDB [(none)]>exit
244Bye原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。