添加官方资源库,去“https://mariadb.org”网站下载,选择“Download”。

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

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