1# Rocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、 Kylin Server、UOS Server、Ubuntu、Debian
2useradd-s /sbin/nologin -r mysql
3
4# openSUSE
5groupadd-r mysql
6useradd-s /sbin/nologin -r-g mysql mysqlMySQL二进制包下载,去“https://www.mysql.com/”网站下载,选择“DOWNLOADS”,如图40所示。

图40 下载MySQL二进制包
选择“MySQL Community (GPL) Downloads”,如图41所示。

图41 下载MySQL二进制包
然后选择“MySQL Community Server”,如图42所示。

图42 下载MySQL二进制包
然后版本选择“8.0.42”,操作系统选择“Linux-Generic”,下面的有5个版本,分别是“glibc 2.28 (x86, 32-bit、x86, 64-bit和ARM, 64-bit)、glibc 2.17 (x86, 32-bit和x86, 64-bit)”,这个根据系统的glibc版本和主机的硬件架构类型下载,图43所示。

图43 下载MySQL二进制包
1[root@rocky10 ~]# dnf info glibc
2Last metadata expiration check: 0:08:38 ago on Tue 10 Jun 202512:21:32 PM CST.
3Installed Packages
4Name : glibc
5Version :2.39# 可以看到Rocky 10的glibc版本是2.39
6Release :37.el10
7Architecture : x86_64
8Size :6.2 M
9Source : glibc-2.39-37.el10.src.rpm
10Repository : @System
11From repo : anaconda
12Summary : The GNU libc libraries
13URL : http://www.gnu.org/software/glibc/
14License : LGPL-2.1-or-later AND SunPro AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND
15: GPL-2.0-or-later AND LGPL-2.1-or-later WITH GNU-compiler-exception AND GPL-2.0-only AND ISC AND
16: LicenseRef-Fedora-Public-Domain AND HPND AND CMU-Mach AND LGPL-2.1-only AND LGPL-2.0-or-later AND
17: Unicode-DFS-2015 AND GFDL-1.1-or-later AND GPL-1.0-or-later AND FSFUL AND MIT AND Inner-Net-2.0
18: AND X11 AND GPL-2.0-or-later WITH GCC-exception-2.0 AND GFDL-1.3-only AND GFDL-1.1-only
19Description : The glibc package contains standard libraries which are used by
20: multiple programs on the system. In order to save disk space and
21: memory, as well as to make upgrading easier, common system code is
22: kept in one place and shared between programs. This particular package
23: contains the most important sets of shared libraries: the standard C
24: library and the standard math library. Without these two libraries, a
25: Linux system will not function.
26
27[root@rocky9 ~]# dnf info glibc
28Last metadata expiration check: 0:10:23 ago on Tue 22 Apr 2025 09:55:39 PM CST.
29Installed Packages
30Name : glibc
31Version :2.34# 可以看到Rocky 9的glibc版本是2.34
32Release :125.el9_5.1
33Architecture : x86_64
34Size :6.1 M
35Source : glibc-2.34-125.el9_5.1.src.rpm
36Repository : @System
37From repo : anaconda
38Summary : The GNU libc libraries
39URL : http://www.gnu.org/software/glibc/
40License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and
41: ISC and Public Domain and GFDL
42Description : The glibc package contains standard libraries which are used by
43: multiple programs on the system. In order to save disk space and
44: memory, as well as to make upgrading easier, common system code is
45: kept in one place and shared between programs. This particular package
46: contains the most important sets of shared libraries: the standard C
47: library and the standard math library. Without these two libraries, a
48: Linux system will not function.
49...
50
51[root@rocky8 ~]# dnf info glibc
52Last metadata expiration check: 0:03:40 ago on Fri 25 Apr 2025 05:47:33 PM CST.
53Installed Packages
54Name : glibc
55Version :2.28# 可以看到Rocky 8的glibc版本是2.28
56Release :251.el8_10.2
57Architecture : x86_64
58Size :6.6 M
59Source : glibc-2.28-251.el8_10.2.src.rpm
60Repository : @System
61From repo : anaconda
62Summary : The GNU libc libraries
63URL : http://www.gnu.org/software/glibc/
64License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and
65: ISC and Public Domain and GFDL
66Description : The glibc package contains standard libraries which are used by
67: multiple programs on the system. In order to save disk space and
68: memory, as well as to make upgrading easier, common system code is
69: kept in one place and shared between programs. This particular package
70: contains the most important sets of shared libraries: the standard C
71: library and the standard math library. Without these two libraries, a
72: Linux system will not function.
73...
74
75[root@almalinux10 ~]# dnf info glibc
76Last metadata expiration check: 0:02:16 ago on Tue 10 Jun 2025 01:44:44 PM CST.
77Installed Packages
78Name : glibc
79Version :2.39# 可以看到Almalinux 10的glibc版本是2.39
80Release :37.el10.alma.1
81Architecture : x86_64
82Size :6.2 M
83Source : glibc-2.39-37.el10.alma.1.src.rpm
84Repository : @System
85From repo : anaconda
86Summary : The GNU libc libraries
87URL : http://www.gnu.org/software/glibc/
88License : LGPL-2.1-or-later AND SunPro AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND
89: GPL-2.0-or-later AND LGPL-2.1-or-later WITH GNU-compiler-exception AND GPL-2.0-only AND ISC AND
90: LicenseRef-Fedora-Public-Domain AND HPND AND CMU-Mach AND LGPL-2.1-only AND LGPL-2.0-or-later AND
91: Unicode-DFS-2015 AND GFDL-1.1-or-later AND GPL-1.0-or-later AND FSFUL AND MIT AND Inner-Net-2.0
92: AND X11 AND GPL-2.0-or-later WITH GCC-exception-2.0 AND GFDL-1.3-only AND GFDL-1.1-only
93Description : The glibc package contains standard libraries which are used by
94: multiple programs on the system. In order to save disk space and
95: memory, as well as to make upgrading easier, common system code is
96: kept in one place and shared between programs. This particular package
97: contains the most important sets of shared libraries: the standard C
98: library and the standard math library. Without these two libraries, a
99: Linux system will not function.
100
101[root@almalinux9 ~]# dnf info glibc
102Last metadata expiration check: 0:00:59 ago on Tue 22 Apr 202511:11:48 PM CST.
103Installed Packages
104Name : glibc
105Version :2.34# 可以看到Almalinux 9的glibc版本是2.34
106Release :125.el9_5.1
107Architecture : x86_64
108Size :6.1 M
109Source : glibc-2.34-125.el9_5.1.src.rpm
110Repository : @System
111From repo : anaconda
112Summary : The GNU libc libraries
113URL : http://www.gnu.org/software/glibc/
114License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and
115: ISC and Public Domain and GFDL
116Description : The glibc package contains standard libraries which are used by
117: multiple programs on the system. In order to save disk space and
118: memory, as well as to make upgrading easier, common system code is
119: kept in one place and shared between programs. This particular package
120: contains the most important sets of shared libraries: the standard C
121: library and the standard math library. Without these two libraries, a
122: Linux system will not function.
123...
124
125[root@almalinux8 ~]# dnf info glibc
126Last metadata expiration check: 0:02:09 ago on Fri 25 Apr 2025 06:36:03 PM CST.
127Installed Packages
128Name : glibc
129Version :2.28# 可以看到Almalinux 8的glibc版本是2.28
130Release :251.el8_10.2
131Architecture : x86_64
132Size :6.6 M
133Source : glibc-2.28-251.el8_10.2.src.rpm
134Repository : @System
135From repo : anaconda
136Summary : The GNU libc libraries
137URL : http://www.gnu.org/software/glibc/
138License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net and
139: ISC and Public Domain and GFDL
140Description : The glibc package contains standard libraries which are used by
141: multiple programs on the system. In order to save disk space and
142: memory, as well as to make upgrading easier, common system code is
143: kept in one place and shared between programs. This particular package
144: contains the most important sets of shared libraries: the standard C
145: library and the standard math library. Without these two libraries, a
146: Linux system will not function.
147...
148
149[root@centos10 ~]# dnf info glibc
150Last metadata expiration check: 0:01:31 ago on Fri 25 Apr 2025 05:25:26 PM CST.
151Installed Packages
152Name : glibc
153Version :2.39# 可以看到CentOS Stream 10的glibc版本是2.39
154Release :37.el10
155Architecture : x86_64
156Size :6.2 M
157Source : glibc-2.39-37.el10.src.rpm
158Repository : @System
159From repo : anaconda
160Summary : The GNU libc libraries
161URL : http://www.gnu.org/software/glibc/
162License : LGPL-2.1-or-later AND SunPro AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND
163: GPL-2.0-or-later AND LGPL-2.1-or-later WITH GNU-compiler-exception AND GPL-2.0-only AND ISC AND
164: LicenseRef-Fedora-Public-Domain AND HPND AND CMU-Mach AND LGPL-2.1-only AND LGPL-2.0-or-later AND
165: Unicode-DFS-2015 AND GFDL-1.1-or-later AND GPL-1.0-or-later AND FSFUL AND MIT AND Inner-Net-2.0 AND
166: X11 AND GPL-2.0-or-later WITH GCC-exception-2.0 AND GFDL-1.3-only AND GFDL-1.1-only
167Description : The glibc package contains standard libraries which are used by
168: multiple programs on the system. In order to save disk space and
169: memory, as well as to make upgrading easier, common system code is
170: kept in one place and shared between programs. This particular package
171: contains the most important sets of shared libraries: the standard C
172: library and the standard math library. Without these two libraries, a
173: Linux system will not function.
174
175[root@centos9 ~]# dnf info glibc
176Last metadata expiration check: 0:00:55 ago on Fri 25 Apr 2025 06:53:50 PM CST.
177Installed Packages
178Name : glibc
179Version :2.34# 可以看到CentOS Stream 9的glibc版本是2.34
180Release :184.el9
181Architecture : x86_64
182Size :6.1 M
183Source : glibc-2.34-184.el9.src.rpm
184Repository : @System
185From repo : baseos
186Summary : The GNU libc libraries
187URL : http://www.gnu.org/software/glibc/
188License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
189: and ISC and Public Domain and GFDL
190Description : The glibc package contains standard libraries which are used by
191: multiple programs on the system. In order to save disk space and
192: memory, as well as to make upgrading easier, common system code is
193: kept in one place and shared between programs. This particular package
194: contains the most important sets of shared libraries: the standard C
195: library and the standard math library. Without these two libraries, a
196: Linux system will not function.
197...
198
199[root@centos8 ~]# dnf info glibc
200Last metadata expiration check: 0:02:56 ago on Fri 25 Apr 2025 07:43:16 PM CST.
201Installed Packages
202Name : glibc
203Version :2.28# 可以看到CentOS Stream 8的glibc版本是2.28
204Release :251.el8
205Architecture : x86_64
206Size :6.6 M
207Source : glibc-2.28-251.el8.src.rpm
208Repository : @System
209From repo : anaconda
210Summary : The GNU libc libraries
211URL : http://www.gnu.org/software/glibc/
212License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
213: and ISC and Public Domain and GFDL
214Description : The glibc package contains standard libraries which are used by
215: multiple programs on the system. In order to save disk space and
216: memory, as well as to make upgrading easier, common system code is
217: kept in one place and shared between programs. This particular package
218: contains the most important sets of shared libraries: the standard C
219: library and the standard math library. Without these two libraries, a
220: Linux system will not function.
221...
222
223[root@centos7 ~]# yum info glibc
224Loaded plugins: fastestmirror
225Repository 'mysql' is missing name in configuration, using id
226Loading mirror speeds from cached hostfile
227Installed Packages
228Name : glibc
229Arch : x86_64
230Version :2.17# 可以看到CentOS 7的glibc版本是2.17
231Release :326.el7_9
232Size :13 M
233Repo : installed
234From repo : anaconda
235Summary : The GNU libc libraries
236URL : http://www.gnu.org/software/glibc/
237License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
238Description : The glibc package contains standard libraries which are used by
239: multiple programs on the system. In order to save disk space and
240: memory, as well as to make upgrading easier, common system code is
241: kept in one place and shared between programs. This particular package
242: contains the most important sets of shared libraries: the standard C
243: library and the standard math library. Without these two libraries, a
244: Linux system will not function.
245...
246
247[root@openeuler2403 ~]# yum info glibc
248Last metadata expiration check: 0:03:19 ago on Fri 25 Apr 2025 08:21:42 PM CST.
249Installed Packages
250Name : glibc
251Version :2.38# 可以看到openEuler 24.03的glibc版本是2.38
252Release :47.oe2403sp1
253Architecture : x86_64
254Size :11 M
255Source : glibc-2.38-47.oe2403sp1.src.rpm
256Repository : @System
257From repo : anaconda
258Summary : The GNU libc libraries
259URL : http://www.gnu.org/software/glibc/
260License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and
261: Inner-Net-2.0 and ISC and Public Domain and GFDL-1.3-only
262Description : The GNU C Library project provides the core libraries for the GNU system and
263: GNU/Linux systems, as well as many other systems that use Linux as the kernel.
264: These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD,
265: OS-specific APIs and more. These APIs include such foundational facilities as
266: open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt,
267: login, exit and more.
268...
269
270[root@openeuler2203 ~]# yum info glibc
271Last metadata expiration check: 0:01:16 ago on Fri 25 Apr 2025 08:40:01 PM CST.
272Installed Packages
273Name : glibc
274Version :2.34# 可以看到openEuler 22.03的glibc版本是2.34
275Release :152.oe2203sp4
276Architecture : x86_64
277Size :11 M
278Source : glibc-2.34-152.oe2203sp4.src.rpm
279Repository : @System
280From repo : anaconda
281Summary : The GNU libc libraries
282URL : http://www.gnu.org/software/glibc/
283License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
284: and ISC and Public Domain and GFDL
285Description : The GNU C Library project provides the core libraries for the GNU system and
286: GNU/Linux systems, as well as many other systems that use Linux as the kernel.
287: These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD,
288: OS-specific APIs and more. These APIs include such foundational facilities as
289: open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt,
290: login, exit and more.
291...
292
293[root@anolisos23 ~]# yum info glibc
294Last metadata expiration check: 0:01:02 ago on Fri Apr 2520:58:58 2025.
295Installed Packages
296Name : glibc
297Version :2.38# 可以看到AnolisOS 23的glibc版本是2.38
298Release :5.an23
299Architecture : x86_64
300Size :7.4 M
301Source : glibc-2.38-5.an23.src.rpm
302Repository : @System
303From repo : anaconda
304Summary : The GNU libc libraries
305URL : http://www.gnu.org/software/glibc/
306License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
307: and ISC and Public Domain and GFDL
308Description : The glibc package contains standard libraries which are used by
309: multiple programs on the system.
310: In order to save disk space and memory, as well as to make upgrading easier,
311: common system code is kept in one place and shared between programs.
312: This particular package contains the most important sets of shared libraries:
313: the standard C library and the standard math library.
314: Without these two libraries, a Linux system will not function.
315...
316
317[root@anolis8 ~]# yum info glibc
318Last metadata expiration check: 0:01:16 ago on Sat 26 Apr 2025 05:10:03 AM CST.
319Installed Packages
320Name : glibc
321Version :2.28# 可以看到AnolisOS 8的glibc版本是2.28
322Release :236.0.1.an8.8
323Architecture : x86_64
324Size :6.4 M
325Source : glibc-2.28-236.0.1.an8.8.src.rpm
326Repository : @System
327From repo : anaconda
328Summary : The GNU libc libraries
329URL : http://www.gnu.org/software/glibc/
330License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
331: and ISC and Public Domain and GFDL
332Description : The glibc package contains standard libraries which are used by
333: multiple programs on the system. In order to save disk space and
334: memory, as well as to make upgrading easier, common system code is
335: kept in one place and shared between programs. This particular package
336: contains the most important sets of shared libraries: the standard C
337: library and the standard math library. Without these two libraries, a
338: Linux system will not function.
339...
340
341[root@opencloudos9 ~]# yum info glibc
342Last metadata expiration check: 0:00:46 ago on Fri 25 Apr 2025 09:36:03 PM CST.
343Installed Packages
344Name : glibc
345Version :2.38# 可以看到OpenCloudOS 9的glibc版本是2.38
346Release :29.oc9
347Architecture : x86_64
348Size :6.6 M
349Source : glibc-2.38-29.oc9.src.rpm
350Repository : @System
351From repo : anaconda
352Summary : The GNU libc libraries
353URL : http://www.gnu.org/software/glibc/
354License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
355: and ISC and Public Domain and GFDL
356Description : The GNU C Library project provides the core libraries for the GNU
357: system and GNU/Linux systems, as well as many other systems that use
358: Linux as the kernel. These libraries provide critical APIs including
359: ISO C11, POSIX.1-2008, BSD, OS-specific APIs and more. These APIs
360: include such foundational facilities as open, read, write, malloc,
361: printf, getaddrinfo, dlopen, pthread_create, crypt, login, exit and more.
362
363[root@opencloudos8 ~]# yum info glibc
364Last metadata expiration check: 0:00:45 ago on Sat 26 Apr 2025 05:54:03 AM CST.
365Installed Packages
366Name : glibc
367Version :2.28# 可以看到OpenCloudOS 9的glibc版本是2.28
368Release :251.oc8.5.ap.1
369Architecture : x86_64
370Size :6.6 M
371Source : glibc-2.28-251.oc8.5.ap.1.src.rpm
372Repository : @System
373From repo : anaconda
374Summary : The GNU libc libraries
375URL : http://www.gnu.org/software/glibc/
376License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
377: and ISC and Public Domain and GFDL
378Description : The glibc package contains standard libraries which are used by
379: multiple programs on the system. In order to save disk space and
380: memory, as well as to make upgrading easier, common system code is
381: kept in one place and shared between programs. This particular package
382: contains the most important sets of shared libraries: the standard C
383: library and the standard math library. Without these two libraries, a
384: Linux system will not function.
385...
386
387[root@kylin10 ~]# yum info glibc
388Last metadata expiration check: 0:03:30 ago on Fri 25 Apr 202510:10:26 PM CST.
389Installed Packages
390Name : glibc
391Version :2.28# 可以看到Kylin Server v10的glibc版本是2.28
392Release :98.p02.ky10
393Architecture : x86_64
394Size :11 M
395Source : glibc-2.28-98.p02.ky10.src.rpm
396Repository : @System
397From repo : anaconda
398Summary : The GNU libc libraries
399URL : http://www.gnu.org/software/glibc/
400License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
401: and ISC and Public Domain and GFDL
402Description : The GNU C Library project provides the core libraries for the GNU system and
403: GNU/Linux systems, as well as many other systems that use Linux as the kernel.
404: These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD,
405: OS-specific APIs and more. These APIs include such foundational facilities as
406: open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt,
407: login, exit and more.
408...
409
410[root@kylin11 ~]# yum info glibc
411Last metadata expiration check: 0:00:08 ago on Sun 14 Sep 202510:44:00 AM CST.
412Installed Packages
413Name : glibc
414Version :2.38# 可以看到Kylin Server v11的glibc版本是2.38
415Release :47.p08.ky11
416Architecture : x86_64
417Size :11 M
418Source : glibc-2.38-47.p08.ky11.src.rpm
419Repository : @System
420From repo : anaconda
421Summary : The GNU libc libraries
422URL : http://www.gnu.org/software/glibc/
423License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and
424: Inner-Net-2.0 and ISC and Public Domain and GFDL-1.3-only
425Description : The GNU C Library project provides the core libraries for the GNU system and
426: GNU/Linux systems, as well as many other systems that use Linux as the kernel.
427: These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD,
428: OS-specific APIs and more. These APIs include such foundational facilities as
429: open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt,
430: login, exit and more.
431...
432
433[root@uos20 ~]# yum info glibc
434Last metadata expiration check: 0:00:51 ago on Fri 25 Apr 202510:26:30 PM CST.
435Installed Packages
436Name : glibc
437Version :2.28# 可以看到Uos Server v10的glibc版本是2.28
438Release :97.uel20.07
439Architecture : x86_64
440Size :13 M
441Source : glibc-2.28-97.uel20.07.src.rpm
442Repository : @System
443From repo : anaconda
444Summary : The GNU libc libraries
445URL : http://www.gnu.org/software/glibc/
446License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ and GPLv2+ with exceptions and BSD and Inner-Net
447: and ISC and Public Domain and GFDL
448Description : The GNU C Library project provides the core libraries for the GNU system and
449: GNU/Linux systems, as well as many other systems that use Linux as the kernel.
450: These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD,
451: OS-specific APIs and more. These APIs include such foundational facilities as
452: open, read, write, malloc, printf, getaddrinfo, dlopen, pthread_create, crypt,
453: login, exit and more.
454
455opensuse15:~ # zypper info glibc
456Loading repository data...
457Reading installed packages...
458
459
460Information for package glibc:
461------------------------------
462Repository : mirror-sle-update
463Name : glibc
464Version :2.38-150600.14.26.1 # 可以看到openSUSE 15的glibc版本是2.38
465Arch : x86_64
466Vendor : SUSE LLC <https://www.suse.com/>
467Installed Size :6.5 MiB
468Installed : Yes
469Status : out-of-date (version 2.38-150600.12.1 installed)
470Source package : glibc-2.38-150600.14.26.1.src
471Upstream URL : https://www.gnu.org/software/libc/libc.html
472Summary : Standard Shared Libraries (from the GNU C Library)
473Description :
474 The GNU C Library provides the most important standard libraries used
475 by nearly all programs: the standard C library, the standard math
476 library, and the POSIX thread library. A system is not functional
477 without these libraries.
478
479root@ubuntu2404:~# ldd --version
480ldd (Ubuntu GLIBC 2.39-0ubuntu8.4)2.39# 可以看到Ubuntu 24.04的glibc版本是2.39
481Copyright (C)2024 Free Software Foundation, Inc.
482This is free software; see the sourcefor copying conditions. There is NO
483warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
484Written by Roland McGrath and Ulrich Drepper.
485
486root@ubuntu2204:~# ldd --version
487ldd (Ubuntu GLIBC 2.35-0ubuntu3.6)2.35# 可以看到Ubuntu 22.04的glibc版本是2.35
488Copyright (C)2022 Free Software Foundation, Inc.
489This is free software; see the sourcefor copying conditions. There is NO
490warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
491Written by Roland McGrath and Ulrich Drepper.
492
493raymond@ubuntu2004:~$ ldd --version
494ldd (Ubuntu GLIBC 2.31-0ubuntu9.9)2.31# 可以看到Ubuntu 20.04的glibc版本是2.31
495Copyright (C)2020 Free Software Foundation, Inc.
496This is free software; see the sourcefor copying conditions. There is NO
497warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
498Written by Roland McGrath and Ulrich Drepper.
499
500raymond@ubuntu1804:~$ ldd --version
501ldd (Ubuntu GLIBC 2.27-3ubuntu1.4)2.27# 可以看到Ubuntu 18.04的glibc版本是2.27
502Copyright (C)2018 Free Software Foundation, Inc.
503This is free software; see the sourcefor copying conditions. There is NO
504warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
505Written by Roland McGrath and Ulrich Drepper.
506
507raymond@debian13:~$ ldd --version
508ldd (Debian GLIBC 2.41-12)2.41# 可以看到Ubuntu 13的glibc版本是2.41
509Copyright (C)2024 Free Software Foundation, Inc.
510This is free software; see the sourcefor copying conditions. There is NO
511warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
512Written by Roland McGrath and Ulrich Drepper.
513
514root@debian12:~# ldd --version
515ldd (Debian GLIBC 2.36-9+deb12u9)2.36# 可以看到Debian 12的glibc版本是2.36
516Copyright (C)2022 Free Software Foundation, Inc.
517This is free software; see the sourcefor copying conditions. There is NO
518warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
519Written by Roland McGrath and Ulrich Drepper.
520
521root@debian11:~# ldd --version
522ldd (Debian GLIBC 2.31-13+deb11u11)2.31# 可以看到Debian 11的glibc版本是2.31
523Copyright (C)2020 Free Software Foundation, Inc.
524This is free software; see the sourcefor copying conditions. There is NO
525warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
526Written by Roland McGrath and Ulrich Drepper.显示当前主机的硬件架构类型:
1[root@rocky10 ~]# arch
2x86_64根据操作系统的glibc版本去下载相应的安装包,这里系统版本选择“Linux - Generic (glibc 2.28) (x86, 64-bit)”,然后选择下面的“mysql-8.0.42-linux-glibc2.28-x86_64.tar.xz”包后面的“Download”进行下载,**注意:**glibc版本大于等于2.28的使用glibc 2.28版的MySQL二进制包,glibc版本小于2.28的使用glibc2.17版的MySQL二进制包,如图44所示。

图44 下载MySQL二进制包
1# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
2yum install-ywget
3
4# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
5yum install-ytar
6
7# Rocky 8/9/10、Almalinux 8/9/10、CentOS Stream 8/9/10、openEuler 22.03/24.03 LTS、AnolisOS 8/23、OpenCloudOS 8/9、Kylin Server v10/v11、UOS Server v20、openSUSE 15、Ubuntu Server 18.04/20.04/22.04/24.04 LTS、Debian 11/12/13:
8wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.42-linux-glibc2.28-x86_64.tar.xz
9tar xf mysql-8.0.42-linux-glibc2.28-x86_64.tar.xz -C /usr/local
10ln-s /usr/local/mysql-8.0.42-linux-glibc2.28-x86_64/ /usr/local/mysql
11
12# CentOS 7
13wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.42-linux-glibc2.17-x86_64.tar.xz
14tar xf mysql-8.0.42-linux-glibc2.17-x86_64.tar.xz -C /usr/local
15ln-s /usr/local/mysql-8.0.42-linux-glibc2.17-x86_64/ /usr/local/mysql
16
17chown-R mysql:mysql /usr/local/mysql/1echo'PATH=/usr/local/mysql/bin/:$PATH'> /etc/profile.d/mysql.sh
2. /etc/profile.d/mysql.sh1cat> /etc/my.cnf <<-EOF
2[mysqld]
3datadir=/data/mysql
4socket=/data/mysql/mysql.sock
5log-error=/data/mysql/mysql.log
6pid-file=/data/mysql/mysql.pid
7
8[client]
9socket=/data/mysql/mysql.sock
10EOFmkdir-p /data/mysql
2
3chown-R mysql:mysql /data/mysql
4
5# /data/mysql 会自动生成,但是/data/必须事先存在
6# --initialize会生成一个初始化密码,--initialize-insecure生成空密码,两种方式任选一种
7mysqld --initialize--user=mysql --datadir=/data/mysql
8
9grep password /data/mysql/mysql.log
102025-04-22T14:36:39.157585Z 6[Note][MY-010454][Server] A temporary password is generated for root@localhost: K39lgjhHlu:U
11# "K39lgjhHlu:U"就是初始化密码
12
13# 生成空密码的root用户
14mysqld --initialize-insecure --user=mysql --datadir=/data/mysqlRocky 8/9/10、Almalinux 8/9/10、CentOS Stream 8/9/10、CentOS 7、openEuler 22.03/24.03 LTS、AnolisOS 8/23、OpenCloudOS 8/9:
1mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
2mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory # 提示确少”libaio.so.1“文件
3
4yum install-y libaio
5
6mysqld --initialize-insecure --user=mysql --datadir=/data/mysqlUbuntu Server 24.04 LTS:
1mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
2mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
3
4root@ubuntu2404:~# apt search libaio
5Sorting... Done
6Full Text Search... Done
7libaio-dev/noble-updates 0.3.113-6build1.1 amd64
8 Linux kernel AIO access library - development files
9
10libaio1t64/noble-updates,now 0.3.113-6build1.1 amd64 [installed,automatic]# 可以看到libaio1t64包已经安装过了
11 Linux kernel AIO access library - shared library
12
13# 创建软链接
14ln-s /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1
15
16mysqld --initialize-insecure --user=mysql --datadir=/data/mysqlUbuntu Server 18.04 LTS:
1mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
2mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
3
4root@ubuntu1804:~# apt search libaio
5Sorting... Done
6Full Text Search... Done
7libaio-dev/bionic-updates 0.3.110-5ubuntu0.1 amd64
8 Linux kernel AIO access library - development files
9
10libaio1/bionic-updates 0.3.110-5ubuntu0.1 amd64
11 Linux kernel AIO access library - shared library
12
13aptinstall-y libaio1
14
15mysqld --initialize-insecure --user=mysql --datadir=/data/mysqDebian 11/12:
1root@debian12:~# mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
2mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
3
4root@debian12:~# apt search libaio
5Sorting... Done
6Full Text Search... Done
7libaio-dev/stable 0.3.113-4 amd64
8 Linux kernel AIO access library - development files
9
10libaio1/stable 0.3.113-4 amd64
11 Linux kernel AIO access library - shared library
12
13aptinstall-y libaio1
14
15root@debian12:~# mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
16mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
17
18root@debian12:~# apt search libnuma
19Sorting... Done
20Full Text Search... Done
21libnuma-dev/stable 2.0.16-1 amd64
22 Development files for libnuma
23
24libnuma1/stable 2.0.16-1 amd64
25 Libraries for controlling NUMA policy
26
27aptinstall-y libnuma1
28
29mysqld --initialize-insecure --user=mysql --datadir=/data/mysqlDebian 13:
1root@debian13:~# mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
2mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
3
4root@debian13:~# apt search libaio
5libaio-dev/stable 0.3.113-8+b1 amd64
6 Linux kernel AIO access library - development files
7
8libaio1t64/stable 0.3.113-8+b1 amd64
9 Linux kernel AIO access library - shared library
10
11aptinstall-y libaio1t64
12
13# 创建软链接
14root@debian13:~# ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1
15
16root@debian13:~# mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
17mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
18
19root@debian13:~# apt search libnuma
20libnuma-dev/stable 2.0.19-1 amd64
21 Development files for libnuma
22
23libnuma1/stable 2.0.19-1 amd64
24 Libraries for controlling NUMA policy
25
26aptinstall-y libnuma1
27
28mysqld --initialize-insecure --user=mysql --datadir=/data/mysqlRocky、Almalinux、CentOS、openEuler、AnolisOS、OpenCloudOS、 Kylin Server、UOS Server、Ubuntu、Debian:
1# Rocky 9/10、Almalinux 9/10、CentOS Stream 9/10默认没有chkconfig包,需要安装
2yum install-ychkconfig
3
4cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
5
6cat> /lib/systemd/system/mysqld.service <<-EOF
7[Unit]
8Description=mysql database server
9After=network.target
10
11[Service]
12Type=notify
13PrivateNetwork=false
14Type=forking
15Restart=no
16TimeoutSec=5min
17IgnoreSIGPIPE=no
18KillMode=process
19GuessMainPID=no
20RemainAfterExit=yes
21SuccessExitStatus=56
22ExecStart=/etc/init.d/mysqld start
23ExecStop=/etc/init.d//mysqld stop
24ExecReload=/etc/init.d/mysqld reload
25
26[Install]
27WantedBy=multi-user.target
28Alias=mysqld.service
29EOF
30
31systemctl daemon-reload && systemctl enable--now mysqldopenSUSE:
1cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2
3# openSUSE
4cat> /usr/lib/systemd/system/mysqld.service <<-EOF
5[Unit]
6Description=mysql database server
7After=network.target
8
9[Service]
10Type=notify
11PrivateNetwork=false
12Type=forking
13Restart=no
14TimeoutSec=5min
15IgnoreSIGPIPE=no
16KillMode=process
17GuessMainPID=no
18RemainAfterExit=yes
19SuccessExitStatus=56
20ExecStart=/etc/init.d/mysqld start
21ExecStop=/etc/init.d//mysqld stop
22ExecReload=/etc/init.d/mysqld reload
23
24[Install]
25WantedBy=multi-user.target
26Alias=mysqld.service
27EOF
28
29# openSUSE
30ln-s /sbin/chkconfig /usr/lib/systemd/systemd-sysv-install
31chkconfig--add mysqld
32
33service mysqld start1# 如果使用的是空密码,就不需要修改口令
2awk'/temporary password/{print $NF}' /data/mysql/mysql.log
3aupYu;uhJ9&y
4
5mysqladmin -uroot -p'aupYu;uhJ9&y' password 123456Rocky 8/9/10、Almalinux 8/9/10、CentOS Stream 8/9/10、CentOS 7、openEuler 22.03/24.03 LTS、AnolisOS 8/23、OpenCloudOS 8/9、Kylin Server v10/v11、UOS Server v20、Ubuntu Server 18.04/20.04/22.04/24.04 LTS、Debian 11、openSUSE:
1[root@rocky10 ~]# mysql
2Welcome to the MySQL monitor. Commands end with ; or \g.
3Your MySQL connection id is 8
4Server version: 8.0.42 MySQL Community Server - GPL
5
6Copyright (c)2000, 2025, Oracle and/or its affiliates.
7
8Oracle is a registered trademark of Oracle Corporation and/or its
9affiliates. Other names may be trademarks of their respective
10owners.
11
12Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
13
14mysql> status
15--------------
16mysql Ver 8.0.42 for Linux on x86_64 (MySQL Community Server - GPL)
17
18Connection id: 8
19Current database:
20Current user: root@localhost
21SSL: Not in use
22Current pager: stdout
23Using outfile: ''
24Using delimiter: ;
25Server version: 8.0.42 MySQL Community Server - GPL
26Protocol version: 10
27Connection: Localhost via UNIX socket
28Server characterset: utf8mb4
29Db characterset: utf8mb4
30Client characterset: utf8mb4
31Conn. characterset: utf8mb4
32UNIX socket: /data/mysql/mysql.sock
33Binary data as: Hexadecimal
34Uptime: 15 sec
35
36Threads: 2 Questions: 5 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.333
37--------------
38
39mysql> show databases;
40+--------------------+
41| Database |
42+--------------------+
43| information_schema |
44| mysql |
45| performance_schema |
46| sys |
47+--------------------+
484 rows inset(0.01 sec)
49
50mysql>exit
51ByeDebian 12/13:
1root@debian13:~# mysql
2mysql: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory
3
4root@debian13:~# apt search libncurses6
5libncurses6/stable 6.5+20250216-2 amd64
6 shared libraries for terminal handling
7
8aptinstall-y libncurses6
9
10root@debian12:~# mysql
11Welcome to the MySQL monitor. Commands end with ; or \g.
12Your MySQL connection id is 8
13Server version: 8.0.42 MySQL Community Server - GPL
14
15Copyright (c)2000, 2025, Oracle and/or its affiliates.
16
17Oracle is a registered trademark of Oracle Corporation and/or its
18affiliates. Other names may be trademarks of their respective
19owners.
20
21Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
22
23mysql> status
24--------------
25mysql Ver 8.0.42 for Linux on x86_64 (MySQL Community Server - GPL)
26
27Connection id: 8
28Current database:
29Current user: root@localhost
30SSL: root@debian13:~# mysql
31Welcome to the MySQL monitor. Commands end with ; or \g.
32Your MySQL connection id is 8
33Server version: 8.0.42 MySQL Community Server - GPL
34
35Copyright (c)2000, 2025, Oracle and/or its affiliates.
36
37Oracle is a registered trademark of Oracle Corporation and/or its
38affiliates. Other names may be trademarks of their respective
39owners.
40
41Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
42
43mysql> status
44--------------
45mysql Ver 8.0.42 for Linux on x86_64 (MySQL Community Server - GPL)
46
47Connection id: 8
48Current database:
49Current user: root@localhost
50SSL: Not in use
51Current pager: stdout
52Using outfile: ''
53Using delimiter: ;
54Server version: 8.0.42 MySQL Community Server - GPL
55Protocol version: 10
56Connection: Localhost via UNIX socket
57Server characterset: utf8mb4
58Db characterset: utf8mb4
59Client characterset: utf8mb4
60Conn. characterset: utf8mb4
61UNIX socket: /data/mysql/mysql.sock
62Binary data as: Hexadecimal
63Uptime: 1 min 11 sec
64
65Threads: 2 Questions: 5 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.070
66--------------
67
68mysql> show databases;
69+--------------------+
70| Database |
71+--------------------+
72| information_schema |
73| mysql |
74| performance_schema |
75| sys |
76+--------------------+
774 rows inset(0.01 sec)
78
79mysql>exit
80ByeShell脚本源码地址:
Gitee:https://gitee.com/raymond9/shell
Github:https://github.com/raymond999999/shell
可以去上面的Gitee或Github代码仓库拉取脚本。
1[root@rocky10 ~]# cat install_mysql_8.0_binary_v3.sh
2#!/bin/bash
3#
4#**********************************************************************************
5#Author: Raymond
6#QQ: 88563128
7#MP: Raymond运维
8#Date: 2025-09-22
9#FileName: install_mysql_8.0_binary_v3.sh
10#URL: https://wx.zsxq.com/group/15555885545422
11#Description: The mysql binary script install supports
12# “Rocky Linux 8, 9 and 10, AlmaLinux 8, 9 and 10, CentOS 7,
13# CentOS Stream 8, 9 and 10, openEuler 22.03 and 24.03 LTS,
14# AnolisOS 8 and 23, OpenCloudOS 8 and 9, Kylin Server v10 and v11,
15# UOS Server v20, Ubuntu Server 18.04, 20.04, 22.04 and 24.04 LTS,
16# Debian 11 , 12 and 13, openSUSE Leap 15“ operating systems.
17#Copyright (C): 2025 All rights reserved
18#**********************************************************************************
19COLOR="echo -e \\033[01;31m"
20END='\033[0m'
21
22os(){
23. /etc/os-release
24MAIN_NAME=`sed-rn'/^NAME=/s@.*="([[:alpha:]]+).*"$@\1@p' /etc/os-release`
25if[${MAIN_NAME}=="Kylin"];then
26MAIN_VERSION_ID=`sed-rn'/^VERSION_ID=/s@.*="([[:alpha:]]+)(.*)"$@\2@p' /etc/os-release`
27else
28MAIN_VERSION_ID=`sed-rn'/^VERSION_ID=/s@.*="?([0-9]+)\.?.*"?@\1@p' /etc/os-release`
29fi
30if[${MAIN_NAME}=="Ubuntu"-o${MAIN_NAME}=="Debian"];then
31FULL_NAME="${PRETTY_NAME}"
32elif[${MAIN_NAME}=="UOS"];then
33FULL_NAME="${NAME}"
34else
35FULL_NAME="${NAME}${VERSION_ID}"
36fi
37}
38
39os
40DATA_DIR=/data/mysql
41
42# mysql 8.0.42 glibc2.28包下载地址:"https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.42-linux-glibc2.28-x86_64.tar.xz"
43# mysql 8.0.42 glibc2.17包下载地址:"https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.42-linux-glibc2.17-x86_64.tar.xz"
44
45if[${MAIN_NAME}=="CentOS"-a${MAIN_VERSION_ID}==7];then
46GLIBC_VERSION=2.17
47else
48GLIBC_VERSION=2.28
49fi
50MYSQL_URL=https://cdn.mysql.com//Downloads/MySQL-8.0/
51MYSQL_FILE="mysql-8.0.42-linux-glibc${GLIBC_VERSION}-x86_64.tar.xz"
52
53check_file(){
54if[${MAIN_NAME}=="Rocky"-o${MAIN_NAME}=="AlmaLinux"-o${MAIN_NAME}=="CentOS"-o${MAIN_NAME}=="Anolis"-o${MAIN_NAME}=="OpenCloudOS"-o${MAIN_NAME}=="Kylin"];then
55rpm-qwget&> /dev/null ||{${COLOR}"安装wget工具,请稍等......"${END};yum install-ywget&> /dev/null;}
56fi
57if[!-e${MYSQL_FILE}];then
58${COLOR}"缺少${MYSQL_FILE}文件"${END}
59${COLOR}'开始下载MySQL二进制安装包,请稍等......'${END}
60wget${MYSQL_URL}${MYSQL_FILE}||{${COLOR}"MySQL二进制安装包下载失败。"${END};exit;}
61else
62${COLOR}"${MYSQL_FILE}文件已准备好。"${END}
63fi
64}
65
66install_mysql(){
67[-d /usr/local/mysql ]&&{${COLOR}"MySQL数据库已存在,安装失败!"${END};exit;}
68${COLOR}"开始安装MySQL数据库,请稍等......"${END}
69if[${MAIN_NAME}=="openSUSE"];then
70id mysql &> /dev/null ||{groupadd-r mysql &&useradd-s /sbin/nologin -r-g mysql mysql;${COLOR}"成功创建mysql用户!"${END};}
71else
72id mysql &> /dev/null ||{useradd-s /sbin/nologin -r mysql ;${COLOR}"成功创建mysql用户!"${END};}
73fi
74if[${MAIN_NAME}=="openEuler"];then
75if[${MAIN_VERSION_ID}==22-o${MAIN_VERSION_ID}==24];then
76 yum install-ytar&> /dev/null
77fi
78fi
79if[${MAIN_NAME}=="Anolis"];then
80if[${MAIN_VERSION_ID}==23];then
81 yum install-ytar&> /dev/null
82fi
83fi
84if[${MAIN_NAME}=="OpenCloudOS"];then
85if[${MAIN_VERSION_ID}==9];then
86 yum install-ytar&> /dev/null
87fi
88fi
89tar xf ${MYSQL_FILE}-C /usr/local/
90MYSQL_DIR=`echo ${MYSQL_FILE}|sed-nr's/^(.*[0-9]).*/\1/p'`
91ln-s /usr/local/${MYSQL_DIR} /usr/local/mysql
92chown-R mysql:mysql /usr/local/mysql/
93echo'PATH=/usr/local/mysql/bin/:$PATH'> /etc/profile.d/mysql.sh
94. /etc/profile.d/mysql.sh
95cat> /etc/my.cnf <<-EOF
96[mysqld]
97datadir=${DATA_DIR}
98socket=${DATA_DIR}/mysql.sock
99log-error=${DATA_DIR}/mysql.log
100pid-file=${DATA_DIR}/mysql.pid
101
102[client]
103socket=${DATA_DIR}/mysql.sock
104EOF
105[-d${DATA_DIR}]||mkdir-p${DATA_DIR}&> /dev/null
106chown-R mysql:mysql ${DATA_DIR}
107if[${MAIN_NAME}=="Rocky"-o${MAIN_NAME}=="AlmaLinux"-o${MAIN_NAME}=="CentOS"-o${MAIN_NAME}=="openEuler"-o${MAIN_NAME}=="Anolis"-o${MAIN_NAME}=="OpenCloudOS"];then
108 yum install-y libaio &> /dev/null
109fi
110if[${MAIN_NAME}=="Ubuntu"];then
111if[${MAIN_VERSION_ID}==24];then
112ln-s /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1
113fi
114if[${MAIN_VERSION_ID}==18];then
115apt update &> /dev/null;aptinstall-y libaio1 &> /dev/null
116fi
117fi
118if[${MAIN_NAME}=="Debian"];then
119if[${MAIN_VERSION_ID}==11-o${MAIN_VERSION_ID}==12];then
120apt update &> /dev/null;aptinstall-y libaio1 libnuma1 &> /dev/null
121fi
122if[${MAIN_VERSION_ID}==13];then
123apt update &> /dev/null;aptinstall-y libaio1t64 libnuma1 &> /dev/null
124ln-s /usr/lib/x86_64-linux-gnu/libaio.so.1t64.0.2 /usr/lib/x86_64-linux-gnu/libaio.so.1
125fi
126if[${MAIN_VERSION_ID}==12-o${MAIN_VERSION_ID}==13];then
127apt update &> /dev/null;aptinstall-y libncurses6 &> /dev/null
128fi
129fi
130 mysqld --initialize-insecure --user=mysql --datadir=${DATA_DIR}
131if[${MAIN_NAME}=="Rocky"];then
132if[${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
133 yum install-ychkconfig&> /dev/null
134fi
135fi
136if[${MAIN_NAME}=="AlmaLinux"];then
137if[${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
138 yum install-ychkconfig&> /dev/null
139fi
140fi
141if[${MAIN_NAME}=="CentOS"];then
142if[${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
143 yum install-ychkconfig&> /dev/null
144fi
145fi
146cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
147if[${MAIN_NAME}=="openSUSE"];then
148cat> /usr/lib/systemd/system/mysqld.service <<-EOF
149[Unit]
150Description=mysql database server
151After=network.target
152
153[Service]
154Type=notify
155PrivateNetwork=false
156Type=forking
157Restart=no
158TimeoutSec=5min
159IgnoreSIGPIPE=no
160KillMode=process
161GuessMainPID=no
162RemainAfterExit=yes
163SuccessExitStatus=56
164ExecStart=/etc/init.d/mysqld start
165ExecStop=/etc/init.d//mysqld stop
166ExecReload=/etc/init.d/mysqld reload
167
168[Install]
169WantedBy=multi-user.target
170Alias=mysqld.service
171EOF
172ln-s /sbin/chkconfig /usr/lib/systemd/systemd-sysv-install
173chkconfig--add mysqld &> /dev/null
174service mysqld start
175else
176cat> /lib/systemd/system/mysqld.service <<-EOF
177[Unit]
178Description=mysql database server
179After=network.target
180
181[Service]
182Type=notify
183PrivateNetwork=false
184Type=forking
185Restart=no
186TimeoutSec=5min
187IgnoreSIGPIPE=no
188KillMode=process
189GuessMainPID=no
190RemainAfterExit=yes
191SuccessExitStatus=56
192ExecStart=/etc/init.d/mysqld start
193ExecStop=/etc/init.d//mysqld stop
194ExecReload=/etc/init.d/mysqld reload
195
196[Install]
197WantedBy=multi-user.target
198Alias=mysqld.service
199EOF
200 systemctl daemon-reload && systemctl enable--now mysqld &> /dev/null
201fi
202[$?-ne0]&&{${COLOR}"数据库启动失败,退出!"${END};exit;}
203${COLOR}"${FULL_NAME}操作系统,MySQL数据库安装完成!"${END}
204}
205
206main(){
207 check_file
208 install_mysql
209}
210
211if[${MAIN_NAME}=="Rocky"];then
212if[${MAIN_VERSION_ID}==8-o${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
213 main
214fi
215elif[${MAIN_NAME}=="AlmaLinux"];then
216if[${MAIN_VERSION_ID}==8-o${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
217 main
218fi
219elif[${MAIN_NAME}=="CentOS"];then
220if[${MAIN_VERSION_ID}==7-o${MAIN_VERSION_ID}==8-o${MAIN_VERSION_ID}==9-o${MAIN_VERSION_ID}==10];then
221 main
222fi
223elif[${MAIN_NAME}=="openEuler"];then
224if[${MAIN_VERSION_ID}==22-o${MAIN_VERSION_ID}==24];then
225 main
226fi
227elif[${MAIN_NAME}=="Anolis"];then
228if[${MAIN_VERSION_ID}==8-o${MAIN_VERSION_ID}==23];then
229 main
230fi
231elif[${MAIN_NAME}=='OpenCloudOS'];then
232if[${MAIN_VERSION_ID}==8-o${MAIN_VERSION_ID}==9];then
233 main
234fi
235elif[${MAIN_NAME}=="Kylin"];then
236if[${MAIN_VERSION_ID}==10-o${MAIN_VERSION_ID}==11];then
237 main
238fi
239elif[${MAIN_NAME}=="UOS"];then
240if[${MAIN_VERSION_ID}==20];then
241 main
242fi
243elif[${MAIN_NAME}=="openSUSE"];then
244if[${MAIN_VERSION_ID}==15];then
245 main
246fi
247elif[${MAIN_NAME}=="Ubuntu"];then
248if[${MAIN_VERSION_ID}==18-o${MAIN_VERSION_ID}==20-o${MAIN_VERSION_ID}==22-o${MAIN_VERSION_ID}==24];then
249 main
250fi
251elif[${MAIN_NAME}=='Debian'];then
252if[${MAIN_VERSION_ID}==11-o${MAIN_VERSION_ID}==12-o${MAIN_VERSION_ID}==13];then
253 main
254fi
255else
256${COLOR}"此脚本不支持${FULL_NAME}操作系统!"${END}
257fi原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。