60 openEuler 22.03-LTS 搭建MySQL數(shù)據(jù)庫服務(wù)器-安裝凑懂、運行和卸載

60 openEuler 22.03-LTS 搭建MySQL數(shù)據(jù)庫服務(wù)器-安裝、運行和卸載60.1 安裝60.2 運行60.3 卸載

60 openEuler 22.03-LTS 搭建MySQL數(shù)據(jù)庫服務(wù)器-安裝涎劈、運行和卸載

60.1 安裝

  1. 配置本地yum源狭魂,詳細信息請參考《openEuler 22.03-LTS 搭建repo服務(wù)器》。

  2. 清除緩存潮针。

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n14" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># dnf clean all</pre>

    例如示例命令如下:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n16" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# dnf clean all
    45 files removed
    [root@superman-21 ~]# </pre>

  3. 創(chuàng)建緩存术荤。

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n19" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># dnf makecache</pre>

    例如示例命令如下:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n21" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# dnf makecache
    OS 6.5 MB/s | 3.4 MB 00:00
    everything 18 MB/s | 16 MB 00:00
    EPOL 5.4 MB/s | 2.6 MB 00:00
    debuginfo 3.2 MB/s | 3.9 MB 00:01
    source 3.9 MB/s | 1.7 MB 00:00
    update 15 MB/s | 29 MB 00:01
    Metadata cache created.
    [root@superman-21 ~]# </pre>

  4. 在root權(quán)限下安裝mariadb服務(wù)器。

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n24" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># dnf install mysql-server</pre>

    例如示例命令如下:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n26" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# dnf install mysql-server
    Last metadata expiration check: 0:45:47 ago on 2022年12月21日 星期三 17時18分58秒.
    Dependencies resolved.
    ====================================================================================================================================
    Package Architecture Version Repository Size
    ====================================================================================================================================
    Installing:
    mysql-server x86_64 8.0.28-1.oe2203 everything 23 M
    Installing dependencies:
    mariadb-config x86_64 4:10.5.16-1.oe2203 update 8.0 k
    mecab x86_64 0.996-2.oe2203 everything 371 k
    mysql x86_64 8.0.28-1.oe2203 OS 10 M
    mysql-common x86_64 8.0.28-1.oe2203 OS 30 k
    mysql-errmsg x86_64 8.0.28-1.oe2203 everything 545 k
    mysql-selinux noarch 1.0.0-2.oe2203 everything 35 k
    protobuf-lite x86_64 3.14.0-6.oe2203 update 217 k

    Transaction Summary

    Install 8 Packages

    Total download size: 35 M
    Installed size: 188 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/8): mysql-common-8.0.28-1.oe2203.x86_64.rpm 241 kB/s | 30 kB 00:00
    (2/8): mecab-0.996-2.oe2203.x86_64.rpm 1.2 MB/s | 371 kB 00:00
    (3/8): mysql-selinux-1.0.0-2.oe2203.noarch.rpm 784 kB/s | 35 kB 00:00
    (4/8): mysql-errmsg-8.0.28-1.oe2203.x86_64.rpm 1.3 MB/s | 545 kB 00:00
    (5/8): mariadb-config-10.5.16-1.oe2203.x86_64.rpm 113 kB/s | 8.0 kB 00:00
    (6/8): protobuf-lite-3.14.0-6.oe2203.x86_64.rpm 1.2 MB/s | 217 kB 00:00
    (7/8): mysql-8.0.28-1.oe2203.x86_64.rpm 7.6 MB/s | 10 MB 00:01
    (8/8): mysql-server-8.0.28-1.oe2203.x86_64.rpm 5.1 MB/s | 23 MB 00:04


    Total 7.1 MB/s | 35 MB 00:04
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
    Preparing : 1/1
    Installing : mariadb-config-4:10.5.16-1.oe2203.x86_64 1/8
    Installing : mysql-common-8.0.28-1.oe2203.x86_64 2/8
    Installing : mysql-8.0.28-1.oe2203.x86_64 3/8
    Installing : mysql-errmsg-8.0.28-1.oe2203.x86_64 4/8
    Installing : protobuf-lite-3.14.0-6.oe2203.x86_64 5/8
    Running scriptlet: mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    Installing : mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    Running scriptlet: mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    libsemanage.semanage_direct_install_info: Overriding mysql module at lower priority 100 with module at priority 200.

    Installing : mecab-0.996-2.oe2203.x86_64 7/8
    Running scriptlet: mecab-0.996-2.oe2203.x86_64 7/8
    Running scriptlet: mysql-server-8.0.28-1.oe2203.x86_64 8/8
    Installing : mysql-server-8.0.28-1.oe2203.x86_64 8/8
    Running scriptlet: mysql-server-8.0.28-1.oe2203.x86_64 8/8
    Running scriptlet: mysql-selinux-1.0.0-2.oe2203.noarch 8/8
    Running scriptlet: mysql-server-8.0.28-1.oe2203.x86_64 8/8
    /usr/lib/tmpfiles.d/pesign.conf:1: Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.

    Verifying : mysql-8.0.28-1.oe2203.x86_64 1/8
    Verifying : mysql-common-8.0.28-1.oe2203.x86_64 2/8
    Verifying : mecab-0.996-2.oe2203.x86_64 3/8
    Verifying : mysql-errmsg-8.0.28-1.oe2203.x86_64 4/8
    Verifying : mysql-selinux-1.0.0-2.oe2203.noarch 5/8
    Verifying : mysql-server-8.0.28-1.oe2203.x86_64 6/8
    Verifying : mariadb-config-4:10.5.16-1.oe2203.x86_64 7/8
    Verifying : protobuf-lite-3.14.0-6.oe2203.x86_64 8/8

    Installed:
    mariadb-config-4:10.5.16-1.oe2203.x86_64 mecab-0.996-2.oe2203.x86_64 mysql-8.0.28-1.oe2203.x86_64
    mysql-common-8.0.28-1.oe2203.x86_64 mysql-errmsg-8.0.28-1.oe2203.x86_64 mysql-selinux-1.0.0-2.oe2203.noarch
    mysql-server-8.0.28-1.oe2203.x86_64 protobuf-lite-3.14.0-6.oe2203.x86_64

    Complete!
    [root@superman-21 ~]# </pre>

  5. 查看安裝后的rpm包每篷。

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n29" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># rpm -qa | grep mysql</pre>

    例如示例命令如下:

    <pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="bash" cid="n31" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# rpm -qa | grep mysql
    mysql-server-8.0.28-1.oe2203.x86_64
    mysql-selinux-1.0.0-2.oe2203.noarch
    mysql-errmsg-8.0.28-1.oe2203.x86_64
    mysql-common-8.0.28-1.oe2203.x86_64
    mysql-8.0.28-1.oe2203.x86_64
    [root@superman-21 ~]# </pre>

60.2 運行

  1. 修改配置文件瓣戚。

    1. 在root權(quán)限下創(chuàng)建my.cnf文件,其中文件路徑(包括軟件安裝路徑basedir焦读、數(shù)據(jù)路徑datadir等)根據(jù)實際情況修改子库。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n39" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># vi /etc/my.cnf</pre>

      編輯my.cnf內(nèi)容如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n41" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">log-error=/data/mysql/log/mysqlerr.log
      pid-file=/data/mysql/run/mysqld.pid
      [mysqldump]
      quick
      [mysql]
      no-auto-rehash
      [client]
      default-character-set=utf8
      [mysqld]
      basedir=/usr/share/mysql
      socket=/data/mysql/run/mysql.sock
      tmpdir=/data/mysql/tmp
      datadir=/data/mysql/data
      lc-messages-dir=/usr/share/mysql
      authentication_policy=mysql_native_password
      port=3306
      user=mysql</pre>

    2. 確保my.cnf配置文件修改正確。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n44" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># cat /etc/my.cnf</pre>

      [圖片上傳失敗...(image-612c7b-1682256412097)]

      注意: 其中basedir為軟件安裝路徑矗晃,請根據(jù)實際情況修改仑嗅。

      例如示例命令如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n48" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# cat /etc/my.cnf
      [mysqld_safe]
      log-error=/data/mysql/log/mysqlerr.log
      pid-file=/data/mysql/run/mysqld.pid
      [mysqldump]
      quick
      [mysql]
      no-auto-rehash
      [client]
      default-character-set=utf8
      [mysqld]
      basedir=/usr/share/mysql
      socket=/data/mysql/run/mysql.sock
      tmpdir=/data/mysql/tmp
      datadir=/data/mysql/data
      lc-messages-dir=/usr/share/mysql
      authentication_policy=mysql_native_password
      port=3306
      user=mysql
      [root@superman-21 ~]# </pre>

    3. 設(shè)置socket軟連接。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n51" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># ln -s /data/mysql/run/mysql.sock /var/lib/mysql/mysql.sock</pre>

      例如示例命令如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n53" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# ln -s /data/mysql/run/mysql.sock /var/lib/mysql/mysql.sock
      [root@superman-21 ~]# </pre>

  2. 在root權(quán)限下初始化數(shù)據(jù)庫张症。

    [圖片上傳失敗...(image-18c3ac-1682256412097)]

    說明: 本步驟倒數(shù)第2行中有初始密碼无畔,請注意保存,登錄數(shù)據(jù)庫時需要使用吠冤。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n58" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># mysqld --defaults-file=/etc/my.cnf --initialize</pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n60" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# mysqld --defaults-file=/etc/my.cnf --initialize
    2022-12-21T11:46:52.711486Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.28) initializing of server in progress as process 9296
    2022-12-21T11:46:52.719415Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2022-12-21T11:46:52.929564Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2022-12-21T11:46:53.791786Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +KmMm/t/q8x4
    [root@superman-21 ~]# </pre>

    查看打印信息,打印信息中包括“initializing of server has completed”表示初始化數(shù)據(jù)庫完成恭理,且打印信息中“A temporary password is generated for root@localhost: +KmMm/t/q8x4”的“+KmMm/t/q8x4”為初始密碼拯辙。

  3. 啟動數(shù)據(jù)庫。

    [圖片上傳失敗...(image-b5fef8-1682256412097)]

    注意: 如果第一次啟動數(shù)據(jù)庫服務(wù)颜价,以root用戶啟動數(shù)據(jù)庫涯保,則啟動時會提示缺少mysql.log文件而導(dǎo)致失敗。使用mysql用戶啟動之后周伦,會在/data/mysql/log目錄下生成mysql.log文件夕春,再次使用root用戶啟動則不會報錯。

    在root權(quán)限下啟動MySQL數(shù)據(jù)庫专挪。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n67" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># systemctl start mysqld </pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n69" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# systemctl start mysqld
    [root@superman-21 ~]#
    [root@superman-21 ~]# systemctl status mysqld
    ● mysqld.service - MySQL 8.0 database server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
    Active: active (running) since Wed 2022-12-21 19:51:29 CST; 6s ago
    Process: 9349 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
    Process: 9372 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
    Main PID: 9408 (mysqld)
    Status: "Server is operational"
    Tasks: 38 (limit: 21420)
    Memory: 362.6M
    CGroup: /system.slice/mysqld.service
    └─ 9408 /usr/libexec/mysqld --basedir=/usr

    12月 21 19:51:20 superman-21 systemd[1]: Starting MySQL 8.0 database server...
    12月 21 19:51:24 superman-21 mysqld[9408]: 2022-12-21T11:51:24.402543Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld >
    12月 21 19:51:24 superman-21 mysqld[9408]: 2022-12-21T11:51:24.447428Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has st>
    12月 21 19:51:28 superman-21 mysqld[9408]: 2022-12-21T11:51:28.034838Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has en>
    12月 21 19:51:29 superman-21 mysqld[9408]: 2022-12-21T11:51:29.808010Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is se>
    12月 21 19:51:29 superman-21 mysqld[9408]: 2022-12-21T11:51:29.808074Z 0 [System] [MY-013602] [Server] Channel mysql_main configure>
    12月 21 19:51:29 superman-21 mysqld[9408]: 2022-12-21T11:51:29.830258Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready f>
    12月 21 19:51:29 superman-21 mysqld[9408]: 2022-12-21T11:51:29.830320Z 0 [System] [MY-011323] [Server] X Plugin ready for connectio>
    12月 21 19:51:29 superman-21 systemd[1]: Started MySQL 8.0 database server.
    [root@superman-21 ~]#</pre>

  4. 登錄數(shù)據(jù)庫及志。

    [圖片上傳失敗...(image-e25e48-1682256412097)]

    說明:

    • 提示輸入密碼時片排,請輸入2產(chǎn)生的初始密碼。
    • 如果采用官網(wǎng)RPM安裝方式速侈,則mysql文件在/usr/bin目錄下率寡。登錄數(shù)據(jù)庫的命令根據(jù)實際情況修改。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n79" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># mysql -uroot -p</pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n81" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 8.0.28

    Copyright (c) 2000, 2022, 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></pre>

  5. 配置數(shù)據(jù)庫帳號密碼倚搬。

    1. 登錄數(shù)據(jù)庫以后冶共,修改通過root用戶登錄數(shù)據(jù)庫的密碼。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n87" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> alter user 'root'@'localhost' identified by "123456";</pre>

      例如示例命令如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n89" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> alter user 'root'@'localhost' identified by "123456";
      Query OK, 0 rows affected (0.01 sec)

      mysql> </pre>

    2. 創(chuàng)建全域root用戶(允許root從其他服務(wù)器訪問)每界。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n92" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> create user 'root'@'%' identified by '123456';</pre>

      例如示例命令如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n94" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> create user 'root'@'%' identified by '123456';
      Query OK, 0 rows affected (0.00 sec)

      mysql> </pre>

    3. 進行授權(quán)捅僵。

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n97" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> grant all privileges on . to 'root'@'%';
      mysql> flush privileges;</pre>

      例如示例命令如下:

      <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n99" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> grant all privileges on . to 'root'@'%';
      Query OK, 0 rows affected (0.01 sec)

      mysql> flush privileges;
      Query OK, 0 rows affected (0.00 sec)

      mysql> </pre>

  6. 退出數(shù)據(jù)庫。

    執(zhí)行 \q 或者 exit 退出數(shù)據(jù)庫眨层。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n103" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> \q
    mysql> exit</pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n105" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">mysql> \q
    Bye
    [root@superman-21 ~]#
    mysql> exit
    Bye
    [root@superman-21 ~]# </pre>

60.3 卸載

  1. 在root權(quán)限下關(guān)閉數(shù)據(jù)庫進程庙楚。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n111" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># systemctl stop mysqld</pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n113" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# systemctl stop mysqld
    [root@superman-21 ~]# </pre>

  2. 在root權(quán)限下執(zhí)行dnf remove mysql命令卸載MySQL。

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n116" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;"># dnf remove mysql</pre>

    例如示例命令如下:

    <pre class="md-fences mock-cm md-end-block" spellcheck="false" lang="bash" cid="n118" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit;">[root@superman-21 ~]# dnf remove mysql
    Dependencies resolved.
    ====================================================================================================================================
    Package Architecture Version Repository Size
    ====================================================================================================================================
    Removing:
    mysql x86_64 8.0.28-1.oe2203 @OS 59 M
    Removing dependent packages:
    mysql-server x86_64 8.0.28-1.oe2203 @everything 117 M
    Removing unused dependencies:
    mariadb-config x86_64 4:10.5.16-1.oe2203 @update 345
    mecab x86_64 0.996-2.oe2203 @everything 2.1 M
    mysql-common x86_64 8.0.28-1.oe2203 @OS 185 k
    mysql-errmsg x86_64 8.0.28-1.oe2203 @everything 9.1 M
    mysql-selinux noarch 1.0.0-2.oe2203 @everything 49 k
    protobuf-lite x86_64 3.14.0-6.oe2203 @update 779 k

    Transaction Summary

    Remove 8 Packages

    Freed space: 188 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.28-1.oe2203.x86_64 1/1
    Running scriptlet: mysql-server-8.0.28-1.oe2203.x86_64 1/8
    Erasing : mysql-server-8.0.28-1.oe2203.x86_64 1/8
    Running scriptlet: mysql-server-8.0.28-1.oe2203.x86_64 1/8
    Erasing : mysql-errmsg-8.0.28-1.oe2203.x86_64 2/8
    Erasing : mysql-8.0.28-1.oe2203.x86_64 3/8
    Erasing : mysql-common-8.0.28-1.oe2203.x86_64 4/8
    Erasing : mariadb-config-4:10.5.16-1.oe2203.x86_64 5/8
    警告:/etc/my.cnf 已另存為 /etc/my.cnf.rpmsave

    Erasing : mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    Running scriptlet: mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    libsemanage.semanage_direct_remove_key: mysql module at priority 100 is now active.

    Erasing : mecab-0.996-2.oe2203.x86_64 7/8
    Running scriptlet: mecab-0.996-2.oe2203.x86_64 7/8
    Erasing : protobuf-lite-3.14.0-6.oe2203.x86_64 8/8
    Running scriptlet: protobuf-lite-3.14.0-6.oe2203.x86_64 8/8
    Verifying : mariadb-config-4:10.5.16-1.oe2203.x86_64 1/8
    Verifying : mecab-0.996-2.oe2203.x86_64 2/8
    Verifying : mysql-8.0.28-1.oe2203.x86_64 3/8
    Verifying : mysql-common-8.0.28-1.oe2203.x86_64 4/8
    Verifying : mysql-errmsg-8.0.28-1.oe2203.x86_64 5/8
    Verifying : mysql-selinux-1.0.0-2.oe2203.noarch 6/8
    Verifying : mysql-server-8.0.28-1.oe2203.x86_64 7/8
    Verifying : protobuf-lite-3.14.0-6.oe2203.x86_64 8/8

    Removed:
    mariadb-config-4:10.5.16-1.oe2203.x86_64 mecab-0.996-2.oe2203.x86_64 mysql-8.0.28-1.oe2203.x86_64
    mysql-common-8.0.28-1.oe2203.x86_64 mysql-errmsg-8.0.28-1.oe2203.x86_64 mysql-selinux-1.0.0-2.oe2203.noarch
    mysql-server-8.0.28-1.oe2203.x86_64 protobuf-lite-3.14.0-6.oe2203.x86_64

    Complete!
    [root@superman-21 ~]#</pre>

?? 點贊谐岁,你的認可是我創(chuàng)作的動力醋奠!

?? 收藏,你的青睞是我努力的方向伊佃!

?? 評論窜司,你的意見是我進步的財富!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末航揉,一起剝皮案震驚了整個濱河市塞祈,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌帅涂,老刑警劉巖议薪,帶你破解...
    沈念sama閱讀 216,544評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異媳友,居然都是意外死亡斯议,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,430評論 3 392
  • 文/潘曉璐 我一進店門醇锚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來哼御,“玉大人,你說我怎么就攤上這事焊唬×抵纾” “怎么了?”我有些...
    開封第一講書人閱讀 162,764評論 0 353
  • 文/不壞的土叔 我叫張陵赶促,是天一觀的道長液肌。 經(jīng)常有香客問我,道長鸥滨,這世上最難降的妖魔是什么嗦哆? 我笑而不...
    開封第一講書人閱讀 58,193評論 1 292
  • 正文 為了忘掉前任谤祖,我火速辦了婚禮,結(jié)果婚禮上吝秕,老公的妹妹穿的比我還像新娘泊脐。我一直安慰自己,他們只是感情好烁峭,可當我...
    茶點故事閱讀 67,216評論 6 388
  • 文/花漫 我一把揭開白布容客。 她就那樣靜靜地躺著,像睡著了一般约郁。 火紅的嫁衣襯著肌膚如雪缩挑。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,182評論 1 299
  • 那天鬓梅,我揣著相機與錄音供置,去河邊找鬼。 笑死绽快,一個胖子當著我的面吹牛芥丧,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播坊罢,決...
    沈念sama閱讀 40,063評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼续担,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了活孩?” 一聲冷哼從身側(cè)響起物遇,我...
    開封第一講書人閱讀 38,917評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎憾儒,沒想到半個月后询兴,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,329評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡起趾,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,543評論 2 332
  • 正文 我和宋清朗相戀三年诗舰,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片训裆。...
    茶點故事閱讀 39,722評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡眶根,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出缭保,到底是詐尸還是另有隱情,我是刑警寧澤蝙茶,帶...
    沈念sama閱讀 35,425評論 5 343
  • 正文 年R本政府宣布艺骂,位于F島的核電站,受9級特大地震影響隆夯,放射性物質(zhì)發(fā)生泄漏钳恕。R本人自食惡果不足惜别伏,卻給世界環(huán)境...
    茶點故事閱讀 41,019評論 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望忧额。 院中可真熱鬧厘肮,春花似錦、人聲如沸睦番。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,671評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽托嚣。三九已至巩检,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間示启,已是汗流浹背兢哭。 一陣腳步聲響...
    開封第一講書人閱讀 32,825評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留夫嗓,地道東北人迟螺。 一個月前我還...
    沈念sama閱讀 47,729評論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像舍咖,于是被迫代替她去往敵國和親矩父。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,614評論 2 353

推薦閱讀更多精彩內(nèi)容