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 安裝
配置本地yum源狭魂,詳細信息請參考《openEuler 22.03-LTS 搭建repo服務(wù)器》。
-
清除緩存潮针。
<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> -
創(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> -
在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 kTransaction 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/8Installed:
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_64Complete!
[root@superman-21 ~]# </pre> -
查看安裝后的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 運行
-
修改配置文件瓣戚。
-
在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> -
確保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> -
設(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>
-
-
在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”為初始密碼拯辙。
-
啟動數(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=/usr12月 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> -
登錄數(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.28Copyright (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>
- 提示輸入密碼時片排,請輸入
-
配置數(shù)據(jù)庫帳號密碼倚搬。
-
登錄數(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>
-
創(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>
-
進行授權(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>
-
-
退出數(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 卸載
-
在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> -
在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 kTransaction 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.rpmsaveErasing : 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/8Removed:
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_64Complete!
[root@superman-21 ~]#</pre>
?? 點贊谐岁,你的認可是我創(chuàng)作的動力醋奠!
?? 收藏,你的青睞是我努力的方向伊佃!
?? 評論窜司,你的意見是我進步的財富!