Bo's Oracle Station

【博客文章2026】MySQL 9.x数据库管理技巧---给初学者的建议1

2026-3-6 17:16| 发布者: admin| 查看: 17| 评论: 0|原作者: Bo Tang

摘要: 本系列博客旨在带领初学者学习MySQL 9.x数据库。系列1主要内容是:通过在Redhat Enterprise Linux 8.x/Oracle Enterprise Linux 8.x操作系统上安装MySQL 9.6的rpm包的方式来获取环境。从log-error中的mysqld.log获取初始密码,并修改初始密码。最后加固MySQL 9.6数据库。
【博客文章2026】MySQL 9.x数据库管理技巧---给初学者的建议1


Author: Bo Tang

1. 下载MySQL 9.6 RPM包

    以Redhat Enterprise Linux 8.x/Oracle Enterprise Linux 8.x作为操作系统为例,下载相应的MySQL 9.6安装包:

[root@station95 ~]# wget  https://dev.mysql.com/get/Downloads/MySQL-9.6/mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar
--2026-03-07 06:23:04--  https://dev.mysql.com/get/Downloads/MySQL-9.6/mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar
Resolving dev.mysql.com (dev.mysql.com)... 184.50.187.187, 2600:1417:76:589::2e31, 2600:1417:76:58b::2e31
Connecting to dev.mysql.com (dev.mysql.com)|184.50.187.187|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com//Downloads/MySQL-9.6/mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar [following]
--2026-03-07 06:23:06--  https://cdn.mysql.com//Downloads/MySQL-9.6/mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar
Resolving cdn.mysql.com (cdn.mysql.com)... 23.49.112.119, 2600:1417:76:588::1d68, 2600:1417:76:580::1d68
Connecting to cdn.mysql.com (cdn.mysql.com)|23.49.112.119|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1132912640 (1.1G) [application/x-tar]
Saving to: ‘mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar’

mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar 100%[============================================================================>]   1.05G  4.54MB/s    in 4m 7s   

2026-03-07 06:27:14 (4.37 MB/s) - ‘mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar’ saved [1132912640/1132912640]

    如果适用,卸载操作系统自带的Mariadb:

[root@station95 ~]# yum list mariadb
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 2:02:47 ago on Fri 06 Mar 2026 05:03:13 AM CST.
Available Packages
mariadb.x86_64                                               3:10.3.17-1.module+el8.1.0+3974+90eded84                                               AppStream
[root@station95 ~]# yum module disable  mariadb
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 2:03:12 ago on Fri 06 Mar 2026 05:03:13 AM CST.
Dependencies resolved.
=========================================================================================================
 Package                              Architecture                        Version                                 Repository                            Size
=========================================================================================================
Disabling modules:
 mariadb                                                                                                                                                    

Transaction Summary
=========================================================================================================

Is this ok [y/N]: y
Complete!
[root@station95 ~]# yum list mariadb
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 2:03:23 ago on Fri 06 Mar 2026 05:03:13 AM CST.
Error: No matching Packages to list
[root@station95 ~]# rm -rf /var/lib/mysql/*

    如果适用,卸载操作系统自带的MySQL 8.x: 
 
[root@station95 ~]# yum list "mysql*"
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 1:13:12 ago on Sat 07 Mar 2026 05:14:02 AM CST.
Installed Packages
mysql.x86_64                                                    8.0.21-1.module+el8.2.0+7855+47abd494                                              @AppStream
mysql-common.x86_64                                             8.0.21-1.module+el8.2.0+7855+47abd494                                              @AppStream
mysql-errmsg.x86_64                                             8.0.21-1.module+el8.2.0+7855+47abd494                                              @AppStream
mysql-server.x86_64                                             8.0.21-1.module+el8.2.0+7855+47abd494                                              @AppStream
Available Packages
mysql-devel.x86_64                                              8.0.21-1.module+el8.2.0+7855+47abd494                                              AppStream 
mysql-libs.x86_64                                               8.0.21-1.module+el8.2.0+7855+47abd494                                              AppStream 
mysql-test.x86_64                                               8.0.21-1.module+el8.2.0+7855+47abd494                                              AppStream 
[root@station95 ~]# yum  remove  "mysql*"
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Dependencies resolved.
========================================================================================================
 Package                                    Architecture           Version                                                  Repository                  Size
========================================================================================================
Removing:
 mysql                                      x86_64                 8.0.21-1.module+el8.2.0+7855+47abd494                    @AppStream                  62 M
 mysql-common                               x86_64                 8.0.21-1.module+el8.2.0+7855+47abd494                    @AppStream                 584 k
 mysql-errmsg                               x86_64                 8.0.21-1.module+el8.2.0+7855+47abd494                    @AppStream                 8.2 M
 mysql-server                               x86_64                 8.0.21-1.module+el8.2.0+7855+47abd494                    @AppStream                 108 M
Removing unused dependencies:
 mariadb-connector-c-config                 noarch                 3.0.7-1.el8                                              @AppStream                 497  
 mecab                                      x86_64                 0.996-1.module+el8.0.0+3898+e09bb8de.9                   @AppStream                 2.2 M
 protobuf-lite                              x86_64                 3.5.0-13.el8                                             @AppStream                 450 k

Transaction Summary
=========================================================================================================
Remove  7 Packages

Freed space: 182 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                     1/1 
  Running scriptlet: mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           1/1 
  Running scriptlet: mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           1/7 
  Erasing          : mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           1/7 
  Running scriptlet: mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           1/7 
  Erasing          : mysql-errmsg-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           2/7 
  Erasing          : mysql-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                                  3/7 
  Erasing          : mysql-common-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           4/7 
  Erasing          : mariadb-connector-c-config-3.0.7-1.el8.noarch                                                                                       5/7 
  Erasing          : mecab-0.996-1.module+el8.0.0+3898+e09bb8de.9.x86_64                                                                                 6/7 
  Running scriptlet: mecab-0.996-1.module+el8.0.0+3898+e09bb8de.9.x86_64                                                                                 6/7 
  Erasing          : protobuf-lite-3.5.0-13.el8.x86_64                                                                                                   7/7 
  Running scriptlet: protobuf-lite-3.5.0-13.el8.x86_64                                                                                                   7/7 
  Verifying        : mariadb-connector-c-config-3.0.7-1.el8.noarch                                                                                       1/7 
  Verifying        : mecab-0.996-1.module+el8.0.0+3898+e09bb8de.9.x86_64                                                                                 2/7 
  Verifying        : mysql-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                                  3/7 
  Verifying        : mysql-common-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           4/7 
  Verifying        : mysql-errmsg-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           5/7 
  Verifying        : mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                                                                           6/7 
  Verifying        : protobuf-lite-3.5.0-13.el8.x86_64                                                                                                   7/7 
Installed products updated.

Removed:
  mariadb-connector-c-config-3.0.7-1.el8.noarch                                 mecab-0.996-1.module+el8.0.0+3898+e09bb8de.9.x86_64                          
  mysql-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                            mysql-common-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                    
  mysql-errmsg-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                     mysql-server-8.0.21-1.module+el8.2.0+7855+47abd494.x86_64                    
  protobuf-lite-3.5.0-13.el8.x86_64                                            

Complete!
[root@station95 ~]# rm -rf /var/lib/mysql/*
 
    安装MySQL Server 9.x:

[root@station95 ~]# tar xvf mysql-9.6.0-1.el8.x86_64.rpm-bundle.tar 
mysql-community-client-9.6.0-1.el8.x86_64.rpm
mysql-community-client-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-client-plugins-9.6.0-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-common-9.6.0-1.el8.x86_64.rpm
mysql-community-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-debugsource-9.6.0-1.el8.x86_64.rpm
mysql-community-devel-9.6.0-1.el8.x86_64.rpm
mysql-community-icu-data-files-9.6.0-1.el8.x86_64.rpm
mysql-community-libs-9.6.0-1.el8.x86_64.rpm
mysql-community-libs-compat-9.6.0-1.el8.x86_64.rpm
mysql-community-libs-compat-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-libs-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-server-9.6.0-1.el8.x86_64.rpm
mysql-community-server-debug-9.6.0-1.el8.x86_64.rpm
mysql-community-server-debug-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-server-debuginfo-9.6.0-1.el8.x86_64.rpm
mysql-community-test-9.6.0-1.el8.x86_64.rpm
mysql-community-test-debuginfo-9.6.0-1.el8.x86_64.rpm

[root@station95 ~]# yum install  *.rpm
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 1:15:30 ago on Sat 07 Mar 2026 05:14:02 AM CST.
Dependencies resolved.
========================================================================================================
 Package                                                    Architecture             Version                            Repository                      Size
========================================================================================================
Installing:
 mysql-community-client                                     x86_64                   9.6.0-1.el8                        @commandline                    15 M
 mysql-community-client-debuginfo                           x86_64                   9.6.0-1.el8                        @commandline                    30 M
 mysql-community-client-plugins                             x86_64                   9.6.0-1.el8                        @commandline                   5.7 M
 mysql-community-client-plugins-debuginfo                   x86_64                   9.6.0-1.el8                        @commandline                   5.5 M
 mysql-community-common                                     x86_64                   9.6.0-1.el8                        @commandline                   726 k
 mysql-community-debuginfo                                  x86_64                   9.6.0-1.el8                        @commandline                   9.1 M
 mysql-community-debugsource                                x86_64                   9.6.0-1.el8                        @commandline                    20 M
 mysql-community-devel                                      x86_64                   9.6.0-1.el8                        @commandline                   8.5 M
 mysql-community-icu-data-files                             x86_64                   9.6.0-1.el8                        @commandline                   2.3 M
 mysql-community-libs                                       x86_64                   9.6.0-1.el8                        @commandline                   1.5 M
 mysql-community-libs-compat                                x86_64                   9.6.0-1.el8                        @commandline                   1.5 M
 mysql-community-libs-compat-debuginfo                      x86_64                   9.6.0-1.el8                        @commandline                   2.8 M
 mysql-community-libs-debuginfo                             x86_64                   9.6.0-1.el8                        @commandline                   2.7 M
 mysql-community-server                                     x86_64                   9.6.0-1.el8                        @commandline                    64 M
 mysql-community-server-debug                               x86_64                   9.6.0-1.el8                        @commandline                    25 M
 mysql-community-server-debug-debuginfo                     x86_64                   9.6.0-1.el8                        @commandline                   168 M
 mysql-community-server-debuginfo                           x86_64                   9.6.0-1.el8                        @commandline                   262 M
 mysql-community-test                                       x86_64                   9.6.0-1.el8                        @commandline                   427 M
 mysql-community-test-debuginfo                             x86_64                   9.6.0-1.el8                        @commandline                    30 M
Installing dependencies:
 keyutils-libs-devel                                        x86_64                   1.5.10-6.el8                       BaseOS                          48 k
 krb5-devel                                                 x86_64                   1.18.2-5.el8                       BaseOS                         558 k
 libcom_err-devel                                           x86_64                   1.45.6-1.el8                       BaseOS                          38 k
 libkadm5                                                   x86_64                   1.18.2-5.el8                       BaseOS                         185 k
 libselinux-devel                                           x86_64                   2.9-3.el8                          BaseOS                         199 k
 libsepol-devel                                             x86_64                   2.9-1.el8                          BaseOS                          86 k
 libverto-devel                                             x86_64                   0.3.0-5.el8                        BaseOS                          18 k
 openssl-devel                                              x86_64                   1:1.1.1g-11.el8                    BaseOS                         2.3 M
 pcre2-devel                                                x86_64                   10.32-2.el8                        BaseOS                         605 k
 pcre2-utf16                                                x86_64                   10.32-2.el8                        BaseOS                         229 k
 pcre2-utf32                                                x86_64                   10.32-2.el8                        BaseOS                         220 k
 perl-JSON                                                  noarch                   2.97.001-2.el8                     AppStream                       96 k
 perl-Memoize                                               noarch                   1.03-416.el8                       AppStream                      118 k
 perl-Time-HiRes                                            x86_64                   1.9758-1.el8                       AppStream                       61 k

Transaction Summary
=========================================================================================================
Install  33 Packages

Total size: 1.1 G
Total download size: 4.7 M
Installed size: 4.2 G
Is this ok [y/N]: y
Downloading Packages:
(1/14): keyutils-libs-devel-1.5.10-6.el8.x86_64.rpm                                                                          4.7 MB/s |  48 kB     00:00    
(2/14): libcom_err-devel-1.45.6-1.el8.x86_64.rpm                                                                             2.8 MB/s |  38 kB     00:00    
(3/14): libkadm5-1.18.2-5.el8.x86_64.rpm                                                                                      16 MB/s | 185 kB     00:00    
(4/14): krb5-devel-1.18.2-5.el8.x86_64.rpm                                                                                    18 MB/s | 558 kB     00:00    
(5/14): libsepol-devel-2.9-1.el8.x86_64.rpm                                                                                  7.8 MB/s |  86 kB     00:00    
(6/14): libselinux-devel-2.9-3.el8.x86_64.rpm                                                                                8.8 MB/s | 199 kB     00:00    
(7/14): libverto-devel-0.3.0-5.el8.x86_64.rpm                                                                                2.7 MB/s |  18 kB     00:00    
(8/14): pcre2-devel-10.32-2.el8.x86_64.rpm                                                                                    20 MB/s | 605 kB     00:00    
(9/14): pcre2-utf16-10.32-2.el8.x86_64.rpm                                                                                   7.1 MB/s | 229 kB     00:00    
(10/14): pcre2-utf32-10.32-2.el8.x86_64.rpm                                                                                   19 MB/s | 220 kB     00:00    
(11/14): perl-JSON-2.97.001-2.el8.noarch.rpm                                                                                 6.4 MB/s |  96 kB     00:00    
(12/14): perl-Memoize-1.03-416.el8.noarch.rpm                                                                                 16 MB/s | 118 kB     00:00    
(13/14): perl-Time-HiRes-1.9758-1.el8.x86_64.rpm                                                                             7.7 MB/s |  61 kB     00:00    
(14/14): openssl-devel-1.1.1g-11.el8.x86_64.rpm                                                                               27 MB/s | 2.3 MB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         37 MB/s | 4.7 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                     1/1 
  Installing       : mysql-community-debugsource-9.6.0-1.el8.x86_64                                                                                     1/33 
  Installing       : mysql-community-debuginfo-9.6.0-1.el8.x86_64                                                                                       2/33 
  Installing       : mysql-community-common-9.6.0-1.el8.x86_64                                                                                          3/33 
  Installing       : mysql-community-client-plugins-9.6.0-1.el8.x86_64                                                                                  4/33 
  Installing       : mysql-community-libs-9.6.0-1.el8.x86_64                                                                                            5/33 
  Running scriptlet: mysql-community-libs-9.6.0-1.el8.x86_64                                                                                            5/33 
  Installing       : mysql-community-client-9.6.0-1.el8.x86_64                                                                                          6/33 
  Installing       : mysql-community-icu-data-files-9.6.0-1.el8.x86_64                                                                                  7/33 
  Running scriptlet: mysql-community-server-9.6.0-1.el8.x86_64                                                                                          8/33 
  Installing       : mysql-community-server-9.6.0-1.el8.x86_64                                                                                          8/33 
  Running scriptlet: mysql-community-server-9.6.0-1.el8.x86_64                                                                                          8/33 
  Installing       : perl-Time-HiRes-1.9758-1.el8.x86_64                                                                                                9/33 
  Installing       : perl-Memoize-1.03-416.el8.noarch                                                                                                  10/33 
  Installing       : perl-JSON-2.97.001-2.el8.noarch                                                                                                   11/33 
  Installing       : pcre2-utf32-10.32-2.el8.x86_64                                                                                                    12/33 
  Installing       : pcre2-utf16-10.32-2.el8.x86_64                                                                                                    13/33 
  Installing       : pcre2-devel-10.32-2.el8.x86_64                                                                                                    14/33 
  Installing       : libverto-devel-0.3.0-5.el8.x86_64                                                                                                 15/33 
  Installing       : libsepol-devel-2.9-1.el8.x86_64                                                                                                   16/33 
  Installing       : libselinux-devel-2.9-3.el8.x86_64                                                                                                 17/33 
  Installing       : libkadm5-1.18.2-5.el8.x86_64                                                                                                      18/33 
  Installing       : libcom_err-devel-1.45.6-1.el8.x86_64                                                                                              19/33 
  Installing       : keyutils-libs-devel-1.5.10-6.el8.x86_64                                                                                           20/33 
  Installing       : krb5-devel-1.18.2-5.el8.x86_64                                                                                                    21/33 
  Installing       : openssl-devel-1:1.1.1g-11.el8.x86_64                                                                                              22/33 
  Installing       : mysql-community-devel-9.6.0-1.el8.x86_64                                                                                          23/33 
  Installing       : mysql-community-test-9.6.0-1.el8.x86_64                                                                                           24/33 
  Installing       : mysql-community-server-debug-9.6.0-1.el8.x86_64                                                                                   25/33 
  Installing       : mysql-community-libs-compat-9.6.0-1.el8.x86_64                                                                                    26/33 
  Running scriptlet: mysql-community-libs-compat-9.6.0-1.el8.x86_64                                                                                    26/33 
  Installing       : mysql-community-client-debuginfo-9.6.0-1.el8.x86_64                                                                               27/33 
  Installing       : mysql-community-client-plugins-debuginfo-9.6.0-1.el8.x86_64                                                                       28/33 
  Installing       : mysql-community-libs-compat-debuginfo-9.6.0-1.el8.x86_64                                                                          29/33 
  Installing       : mysql-community-libs-debuginfo-9.6.0-1.el8.x86_64                                                                                 30/33 
  Installing       : mysql-community-server-debug-debuginfo-9.6.0-1.el8.x86_64                                                                         31/33 
  Installing       : mysql-community-server-debuginfo-9.6.0-1.el8.x86_64                                                                               32/33 
  Installing       : mysql-community-test-debuginfo-9.6.0-1.el8.x86_64                                                                                 33/33 
  Running scriptlet: mysql-community-test-debuginfo-9.6.0-1.el8.x86_64                                                                                 33/33 
  Verifying        : keyutils-libs-devel-1.5.10-6.el8.x86_64                                                                                            1/33 
  Verifying        : krb5-devel-1.18.2-5.el8.x86_64                                                                                                     2/33 
  Verifying        : libcom_err-devel-1.45.6-1.el8.x86_64                                                                                               3/33 
  Verifying        : libkadm5-1.18.2-5.el8.x86_64                                                                                                       4/33 
  Verifying        : libselinux-devel-2.9-3.el8.x86_64                                                                                                  5/33 
  Verifying        : libsepol-devel-2.9-1.el8.x86_64                                                                                                    6/33 
  Verifying        : libverto-devel-0.3.0-5.el8.x86_64                                                                                                  7/33 
  Verifying        : openssl-devel-1:1.1.1g-11.el8.x86_64                                                                                               8/33 
  Verifying        : pcre2-devel-10.32-2.el8.x86_64                                                                                                     9/33 
  Verifying        : pcre2-utf16-10.32-2.el8.x86_64                                                                                                    10/33 
  Verifying        : pcre2-utf32-10.32-2.el8.x86_64                                                                                                    11/33 
  Verifying        : perl-JSON-2.97.001-2.el8.noarch                                                                                                   12/33 
  Verifying        : perl-Memoize-1.03-416.el8.noarch                                                                                                  13/33 
  Verifying        : perl-Time-HiRes-1.9758-1.el8.x86_64                                                                                               14/33 
  Verifying        : mysql-community-client-9.6.0-1.el8.x86_64                                                                                         15/33 
  Verifying        : mysql-community-client-debuginfo-9.6.0-1.el8.x86_64                                                                               16/33 
  Verifying        : mysql-community-client-plugins-9.6.0-1.el8.x86_64                                                                                 17/33 
  Verifying        : mysql-community-client-plugins-debuginfo-9.6.0-1.el8.x86_64                                                                       18/33 
  Verifying        : mysql-community-common-9.6.0-1.el8.x86_64                                                                                         19/33 
  Verifying        : mysql-community-debuginfo-9.6.0-1.el8.x86_64                                                                                      20/33 
  Verifying        : mysql-community-debugsource-9.6.0-1.el8.x86_64                                                                                    21/33 
  Verifying        : mysql-community-devel-9.6.0-1.el8.x86_64                                                                                          22/33 
  Verifying        : mysql-community-icu-data-files-9.6.0-1.el8.x86_64                                                                                 23/33 
  Verifying        : mysql-community-libs-9.6.0-1.el8.x86_64                                                                                           24/33 
  Verifying        : mysql-community-libs-compat-9.6.0-1.el8.x86_64                                                                                    25/33 
  Verifying        : mysql-community-libs-compat-debuginfo-9.6.0-1.el8.x86_64                                                                          26/33 
  Verifying        : mysql-community-libs-debuginfo-9.6.0-1.el8.x86_64                                                                                 27/33 
  Verifying        : mysql-community-server-9.6.0-1.el8.x86_64                                                                                         28/33 
  Verifying        : mysql-community-server-debug-9.6.0-1.el8.x86_64                                                                                   29/33 
  Verifying        : mysql-community-server-debug-debuginfo-9.6.0-1.el8.x86_64                                                                         30/33 
  Verifying        : mysql-community-server-debuginfo-9.6.0-1.el8.x86_64                                                                               31/33 
  Verifying        : mysql-community-test-9.6.0-1.el8.x86_64                                                                                           32/33 
  Verifying        : mysql-community-test-debuginfo-9.6.0-1.el8.x86_64                                                                                 33/33 
Installed products updated.

Installed:
  keyutils-libs-devel-1.5.10-6.el8.x86_64                                           krb5-devel-1.18.2-5.el8.x86_64                                           
  libcom_err-devel-1.45.6-1.el8.x86_64                                              libkadm5-1.18.2-5.el8.x86_64                                             
  libselinux-devel-2.9-3.el8.x86_64                                                 libsepol-devel-2.9-1.el8.x86_64                                          
  libverto-devel-0.3.0-5.el8.x86_64                                                 mysql-community-client-9.6.0-1.el8.x86_64                                
  mysql-community-client-debuginfo-9.6.0-1.el8.x86_64                               mysql-community-client-plugins-9.6.0-1.el8.x86_64                        
  mysql-community-client-plugins-debuginfo-9.6.0-1.el8.x86_64                       mysql-community-common-9.6.0-1.el8.x86_64                                
  mysql-community-debuginfo-9.6.0-1.el8.x86_64                                      mysql-community-debugsource-9.6.0-1.el8.x86_64                           
  mysql-community-devel-9.6.0-1.el8.x86_64                                          mysql-community-icu-data-files-9.6.0-1.el8.x86_64                        
  mysql-community-libs-9.6.0-1.el8.x86_64                                           mysql-community-libs-compat-9.6.0-1.el8.x86_64                           
  mysql-community-libs-compat-debuginfo-9.6.0-1.el8.x86_64                          mysql-community-libs-debuginfo-9.6.0-1.el8.x86_64                        
  mysql-community-server-9.6.0-1.el8.x86_64                                         mysql-community-server-debug-9.6.0-1.el8.x86_64                          
  mysql-community-server-debug-debuginfo-9.6.0-1.el8.x86_64                         mysql-community-server-debuginfo-9.6.0-1.el8.x86_64                      
  mysql-community-test-9.6.0-1.el8.x86_64                                           mysql-community-test-debuginfo-9.6.0-1.el8.x86_64                        
  openssl-devel-1:1.1.1g-11.el8.x86_64                                              pcre2-devel-10.32-2.el8.x86_64                                           
  pcre2-utf16-10.32-2.el8.x86_64                                                    pcre2-utf32-10.32-2.el8.x86_64                                           
  perl-JSON-2.97.001-2.el8.noarch                                                   perl-Memoize-1.03-416.el8.noarch                                         
  perl-Time-HiRes-1.9758-1.el8.x86_64                                              

Complete!

2. 启动MySQL Server 9.6

[root@station95 mysql9.6]# systemctl start mysqld

3. 查看my.cnf确定datadir和log-error分别在哪里

[root@station95 ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# https://dev.mysql.com/doc/refman/9.6/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

   datadir里的内容: 

[root@station95 ~]# cd /var/lib/mysql
[root@station95 mysql]# ls
 auto.cnf        ca-key.pem        client-key.pem       ib_buffer_pool  '#innodb_redo'   mysql.ibd         mysql_upgrade_history   public_key.pem    sys
 binlog.000001   ca.pem           '#ib_16384_0.dblwr'   ibdata1         '#innodb_temp'   mysql.sock        performance_schema      server-cert.pem   undo_001
 binlog.index    client-cert.pem  '#ib_16384_1.dblwr'   ibtmp1           mysql           mysql.sock.lock   private_key.pem         server-key.pem    undo_002
    
    每个数据库都有一个同名的目录。
    log-error里的内容:

[root@station95 log]# ls -l mysqld.log
-rw-r----- 1 mysql mysql 1891 Mar  7 06:35 mysqld.log

4. 从log-error中的mysqld.log获取初始密码:

[root@station95 log]# cat mysqld.log
2026-03-06T22:35:13.328953Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2026-03-06T22:35:13.344370Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 9.6.0) initializing of server in progress as process 4011978
2026-03-06T22:35:13.379831Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2026-03-06T22:35:13.743649Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2026-03-06T22:35:16.407516Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .J%R2)Oe33wt
2026-03-06T22:35:19.599937Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2026-03-06T22:35:19.698042Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2026-03-06T22:35:20.165601Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.6.0) starting as process 4012016
2026-03-06T22:35:20.165638Z 0 [System] [MY-015590] [Server] MySQL Server has access to 8 logical CPUs.
2026-03-06T22:35:20.165657Z 0 [System] [MY-015590] [Server] MySQL Server has access to 117945032704 bytes of physical memory.
2026-03-06T22:35:20.187364Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2026-03-06T22:35:20.567259Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2026-03-06T22:35:21.164685Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2026-03-06T22:35:21.164780Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2026-03-06T22:35:21.221912Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2026-03-06T22:35:21.222003Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '9.6.0'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.

    修改初始密码:

[root@station95 log]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 9.6.0

Copyright (c) 2000, 2026, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>  alter user 'root'@'localhost' identified by 'oracle_4U';
Query OK, 0 rows affected (0.015 sec)

5. 加固:

[root@station95 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 


路过

雷人

握手

鲜花

鸡蛋

QQ|手机版|Bo's Oracle Station   

GMT+8, 2026-3-8 21:25 , Processed in 0.059129 second(s), 21 queries .

返回顶部