国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

在CentOS上用yum方式安裝MySQL8過程記錄

這篇具有很好參考價值的文章主要介紹了在CentOS上用yum方式安裝MySQL8過程記錄。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

此文參考官方文檔一步一步記錄安裝到正常運行全過程

安裝環(huán)境:centos7
mysql版本:8.0.35

安裝過程主要參考下面兩邊文章:
1.官方文檔
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
2.linux yum安裝mysql8

安裝過程大概有以下幾步:
1.查找mysql源鏈接
2.安裝mysql源(倉庫)
3.安裝mysql服務(wù)
4.啟動mysql服務(wù)
5.獲取并修改密碼
6.防火墻放行、遠程登錄和設(shè)置

因為我的這個centos之前用寶塔裝過mysql5.6版本,所以走了一點彎路,過程也記錄下來了。如果也是同樣情況,建議一開始就卸載舊版本再安裝8.0版本。

另外,我避開下面的坑,又重新記錄了在一臺centosh上mysql8.0過程,可以參考下面我寫的另外一篇文章:
《在CentOS上用yum方式安裝MySQL8真實全過程記錄(順利版本)》

一、查找mysql源鏈接

(MySQL Yum Repository,找MySQL官方y(tǒng)um倉庫地址并下載)
根據(jù)官方文檔提示,進入到mysql yum倉庫的下載頁面(如下圖)
https://dev.mysql.com/downloads/repo/yum/

在CentOS上用yum方式安裝MySQL8過程記錄,Linux,系統(tǒng)管理和服務(wù)器,數(shù)據(jù)庫,centos,linux,運維,mysql
因為我的CentOS版本是7,所以選擇對應(yīng)的版本,點擊download進入下載頁面(如下圖)
在CentOS上用yum方式安裝MySQL8過程記錄,Linux,系統(tǒng)管理和服務(wù)器,數(shù)據(jù)庫,centos,linux,運維,mysql
提示注冊,不需要注冊,我們直接復(fù)制下面的下載地址即可。
復(fù)制到的地址為:
https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm

二、安裝mysql源(倉庫)

[root@szaliyun ~]# yum localinstall https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm
已加載插件:fastestmirror
mysql80-community-release-el7-11.noarch.rpm                                                                                                                             |  14 kB  00:00:00     
正在檢查 /var/tmp/yum-root-hMU7pD/mysql80-community-release-el7-11.noarch.rpm: mysql80-community-release-el7-11.noarch
/var/tmp/yum-root-hMU7pD/mysql80-community-release-el7-11.noarch.rpm 將被安裝
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 mysql80-community-release.noarch.0.el7-11 將被 安裝
--> 解決依賴關(guān)系完成

依賴關(guān)系解決

===============================================================================================================================================================================================
 Package                                            架構(gòu)                            版本                               源                                                                 大小
===============================================================================================================================================================================================
正在安裝:
 mysql80-community-release                          noarch                          el7-11                             /mysql80-community-release-el7-11.noarch                           17 k

事務(wù)概要
===============================================================================================================================================================================================
安裝  1 軟件包

總計:17 k
安裝大?。?7 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : mysql80-community-release-el7-11.noarch                                                                                                                                    1/1 
  驗證中      : mysql80-community-release-el7-11.noarch                                                                                                                                    1/1 

已安裝:
  mysql80-community-release.noarch 0:el7-11                                                                                                                                                    

完畢!

過程中提問是否安裝,輸入y后回車。

三、安裝mysql服務(wù)

列出已啟用的包含 “mysql.-community.” 關(guān)鍵字的軟件包倉庫

[root@szaliyun ~]# yum repolist enabled
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
源標識                                                                               源名稱                                                                                            狀態(tài)
base/7/x86_64                                                                        CentOS-7                                                                                          10,070+2
epel/x86_64                                                                          Extra Packages for Enterprise Linux 7 - x86_64                                                    13,788+2
extras/7/x86_64                                                                      CentOS-7                                                                                               518
mysql-connectors-community/x86_64                                                    MySQL Connectors Community                                                                             234
mysql-tools-community/x86_64                                                         MySQL Tools Community                                                                                  102
mysql80-community/x86_64                                                             MySQL 8.0 Community Server                                                                             446
updates/7/x86_64                                                                     CentOS-7                                                                                           5,359+8
repolist: 30,517
[root@szaliyun ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                 234
mysql-tools-community/x86_64      MySQL Tools Community                      102
mysql80-community/x86_64          MySQL 8.0 Community Server                 446
[root@szaliyun ~]# 

yum repolist enabled 用于列出已啟用的軟件包倉庫,grep “mysql.-community.” 用于過濾出包含 “mysql.-community.” 關(guān)鍵字的軟件包倉庫。

安裝

[root@szaliyun ~]# yum install mysql-community-server
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                                    | 3.6 kB  00:00:00     
epel                                                                                                                                                                    | 4.7 kB  00:00:00     
extras                                                                                                                                                                  | 2.9 kB  00:00:00     
mysql-connectors-community                                                                                                                                              | 2.6 kB  00:00:00     
mysql-tools-community                                                                                                                                                   | 2.6 kB  00:00:19     
mysql80-community                                                                                                                                                       | 2.6 kB  00:00:04     
updates                                                                                                                                                                 | 2.9 kB  00:00:00     
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 mysql-community-server.x86_64.0.8.0.35-1.el7 將被 安裝
--> 正在處理依賴關(guān)系 mysql-community-common(x86-64) = 8.0.35-1.el7,它被軟件包 mysql-community-server-8.0.35-1.el7.x86_64 需要
--> 正在處理依賴關(guān)系 mysql-community-icu-data-files = 8.0.35-1.el7,它被軟件包 mysql-community-server-8.0.35-1.el7.x86_64 需要
--> 正在處理依賴關(guān)系 mysql-community-client(x86-64) >= 8.0.11,它被軟件包 mysql-community-server-8.0.35-1.el7.x86_64 需要
--> 正在檢查事務(wù)
---> 軟件包 mysql-community-client.x86_64.0.8.0.35-1.el7 將被 安裝
--> 正在處理依賴關(guān)系 mysql-community-client-plugins = 8.0.35-1.el7,它被軟件包 mysql-community-client-8.0.35-1.el7.x86_64 需要
--> 正在處理依賴關(guān)系 mysql-community-libs(x86-64) >= 8.0.11,它被軟件包 mysql-community-client-8.0.35-1.el7.x86_64 需要
---> 軟件包 mysql-community-common.x86_64.0.8.0.35-1.el7 將被 安裝
---> 軟件包 mysql-community-icu-data-files.x86_64.0.8.0.35-1.el7 將被 安裝
--> 正在檢查事務(wù)
---> 軟件包 mariadb-libs.x86_64.1.5.5.68-1.el7 將被 取代
--> 正在處理依賴關(guān)系 libmysqlclient.so.18()(64bit),它被軟件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在處理依賴關(guān)系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被軟件包 2:postfix-2.10.1-9.el7.x86_64 需要
---> 軟件包 mysql-community-client-plugins.x86_64.0.8.0.35-1.el7 將被 安裝
---> 軟件包 mysql-community-libs.x86_64.0.8.0.35-1.el7 將被 舍棄
--> 正在檢查事務(wù)
---> 軟件包 mysql-community-libs-compat.x86_64.0.8.0.35-1.el7 將被 舍棄
--> 解決依賴關(guān)系完成

依賴關(guān)系解決

===============================================================================================================================================================================================
 Package                                                    架構(gòu)                               版本                                        源                                             大小
===============================================================================================================================================================================================
正在安裝:
 mysql-community-libs                                       x86_64                             8.0.35-1.el7                                mysql80-community                             1.5 M
      替換  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat                                x86_64                             8.0.35-1.el7                                mysql80-community                             669 k
      替換  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-server                                     x86_64                             8.0.35-1.el7                                mysql80-community                              64 M
為依賴而安裝:
 mysql-community-client                                     x86_64                             8.0.35-1.el7                                mysql80-community                              16 M
 mysql-community-client-plugins                             x86_64                             8.0.35-1.el7                                mysql80-community                             3.5 M
 mysql-community-common                                     x86_64                             8.0.35-1.el7                                mysql80-community                             665 k
 mysql-community-icu-data-files                             x86_64                             8.0.35-1.el7                                mysql80-community                             2.2 M

事務(wù)概要
===============================================================================================================================================================================================
安裝  3 軟件包 (+4 依賴軟件包)

總下載量:89 M
Is this ok [y/d/N]: y
Downloading packages:
mysql-community-client-8.0.35- FAILED                                             0% [                                                                       ] 1.1 kB/s |  46 kB  23:13:17 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-client-plugins FAILED                                             0% [                                                                       ] 1.4 kB/s | 280 kB  18:15:11 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-common-8.0.35- FAILED                                            0% [                                                                      ]  2.1 B/s | 434 kB 12427:49:49 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-common-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-common-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-icu-data-files FAILED                                            0% [                                                                       ]  5.4 B/s |  68 kB 4752:59:45 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-libs-8.0.35-1. FAILED                                            0% [                                                                      ]  0.8 B/s | 184 kB 31857:32:53 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-libs-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-libs-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-libs-compat-8. FAILED                                            0% [                                                                       ]  9.6 B/s | 550 kB 2674:52:24 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-libs-compat-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-libs-compat-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。

mysql-community-server-8.0.35- FAILED                                          
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-server-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-server-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
mysql-community-client-8.0.35- FAILED                                            0% [-                                                                      ]  5.6 B/s | 804 kB 4605:51:37 ETA 
http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.35-1.el7.x86_64.rpm: [Errno 12] Timeout on http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.35-1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在嘗試其它鏡像。
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm: 頭V4 RSA/SHA256 Signature, 密鑰 ID 3a79bd29: NOKEYkB/s | 3.3 MB  00:01:59 ETA 
mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm 的公鑰尚未安裝
(1/7): mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm                                                                                                           | 3.5 MB  00:00:02     
(2/7): mysql-community-common-8.0.35-1.el7.x86_64.rpm                                                                                                                   | 665 kB  00:00:00     
(3/7): mysql-community-icu-data-files-8.0.35-1.el7.x86_64.rpm                                                                                                           | 2.2 MB  00:00:00     
(4/7): mysql-community-libs-8.0.35-1.el7.x86_64.rpm                                                                                                                     | 1.5 MB  00:00:00     
(5/7): mysql-community-libs-compat-8.0.35-1.el7.x86_64.rpm                                                                                                              | 669 kB  00:00:00     
(6/7): mysql-community-server-8.0.35-1.el7.x86_64.rpm                                                                                                                   |  64 MB  00:00:10     
(7/7): mysql-community-client-8.0.35-1.el7.x86_64.rpm                                                                                                                   |  16 MB  00:00:02     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
總計                                                                                                                                                            71 kB/s |  89 MB  00:21:14     
從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023 檢索密鑰
導(dǎo)入 GPG key 0xA8D3785C:
 用戶ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指紋       : bca4 3417 c3b4 85dd 128e c6d4 b7b3 b788 a8d3 785c
 軟件包     : mysql80-community-release-el7-11.noarch (@/mysql80-community-release-el7-11.noarch)
 來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
是否繼續(xù)?[y/N]:從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 檢索密鑰
導(dǎo)入 GPG key 0x3A79BD29:
 用戶ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指紋       : 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
 軟件包     : mysql80-community-release-el7-11.noarch (@/mysql80-community-release-el7-11.noarch)
 來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
是否繼續(xù)?[y/N]:y
從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 檢索密鑰
導(dǎo)入 GPG key 0x5072E1F5:
 用戶ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指紋       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 軟件包     : mysql80-community-release-el7-11.noarch (@/mysql80-community-release-el7-11.noarch)
 來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否繼續(xù)?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : mysql-community-common-8.0.35-1.el7.x86_64                                                                                                                                 1/8 
  正在安裝    : mysql-community-client-plugins-8.0.35-1.el7.x86_64                                                                                                                         2/8 
  正在安裝    : mysql-community-libs-8.0.35-1.el7.x86_64                                                                                                                                   3/8 
  正在安裝    : mysql-community-client-8.0.35-1.el7.x86_64                                                                                                                                 4/8 
  正在安裝    : mysql-community-icu-data-files-8.0.35-1.el7.x86_64                                                                                                                         5/8 
  正在安裝    : mysql-community-server-8.0.35-1.el7.x86_64                                                                                                                                 6/8 
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  正在安裝    : mysql-community-libs-compat-8.0.35-1.el7.x86_64                                                                                                                            7/8 
  正在刪除    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                         8/8 
  驗證中      : mysql-community-client-plugins-8.0.35-1.el7.x86_64                                                                                                                         1/8 
  驗證中      : mysql-community-common-8.0.35-1.el7.x86_64                                                                                                                                 2/8 
  驗證中      : mysql-community-icu-data-files-8.0.35-1.el7.x86_64                                                                                                                         3/8 
  驗證中      : mysql-community-libs-8.0.35-1.el7.x86_64                                                                                                                                   4/8 
  驗證中      : mysql-community-client-8.0.35-1.el7.x86_64                                                                                                                                 5/8 
  驗證中      : mysql-community-libs-compat-8.0.35-1.el7.x86_64                                                                                                                            6/8 
  驗證中      : mysql-community-server-8.0.35-1.el7.x86_64                                                                                                                                 7/8 
  驗證中      : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                         8/8 

已安裝:
  mysql-community-libs.x86_64 0:8.0.35-1.el7                  mysql-community-libs-compat.x86_64 0:8.0.35-1.el7                  mysql-community-server.x86_64 0:8.0.35-1.el7                 

作為依賴被安裝:
  mysql-community-client.x86_64 0:8.0.35-1.el7                      mysql-community-client-plugins.x86_64 0:8.0.35-1.el7              mysql-community-common.x86_64 0:8.0.35-1.el7             
  mysql-community-icu-data-files.x86_64 0:8.0.35-1.el7             

替代:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                                                                                                                           

完畢!
[root@szaliyun ~]# 

可以看到安裝并不順利,程序自動更換鏡像后安裝最終完成。

四、啟動mysql服務(wù)

[root@szaliyun ~]# systemctl status mysqld

啟動失敗,查日志
[root@szaliyun ~]# journalctl -xe | grep mysql
查到說redo log格式不對

1026 07:14:54 szaliyun mysqld[19819]: 2023-10-25T23:14:53.988237Z 1 [ERROR] [MY-013090] [InnoDB] Unsupported redo log format (v0). The redo log was created before MySQL 5.7.9

按網(wǎng)上查了一下,說是需要將ib_logfile0和ib_logfile1移走
于是查找并移走這兩個文件,重啟依舊報錯,說找不到目錄

Neither found #innodb_redo subdirectory, nor ib_logfile* files in /www/server/data/

嘗試了網(wǎng)上說的一些方法,也解決不了,估計是mysql5.7版本沒卸載導(dǎo)致8.0不能正常運行。
實在沒辦法就卸載重裝吧:

[root@szaliyun ~]# rpm -qa | grep -i mysql
bt-mysql56-5.6.50-1.el7.x86_64
mysql-community-libs-8.0.35-1.el7.x86_64
mysql-community-libs-compat-8.0.35-1.el7.x86_64
mysql-community-client-plugins-8.0.35-1.el7.x86_64
mysql-community-client-8.0.35-1.el7.x86_64
mysql-community-server-8.0.35-1.el7.x86_64
mysql80-community-release-el7-11.noarch
mysql-community-common-8.0.35-1.el7.x86_64
mysql-community-icu-data-files-8.0.35-1.el7.x86_64
[root@szaliyun ~]# 
[root@szaliyun ~]# yum remove bt-mysql56-5.6.50-1.el7.x86_64
[root@szaliyun ~]# yum remove mysql-community-server-8.0.35-1.el7.x86_64
[root@szaliyun ~]# yum install mysql-community-server

啟動mysql,繼續(xù)報錯:

[root@szaliyun ~]# cat /var/log/mysqld.log
2023-10-29T08:28:10.584709Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.35) initializing of server in progress as process 21123
2023-10-29T08:28:10.589908Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2023-10-29T08:28:10.589953Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2023-10-29T08:28:10.590006Z 0 [ERROR] [MY-010119] [Server] Aborting

關(guān)鍵是這一條:2023-10-29T08:28:10.589953Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
大概是說指定的這個目錄不可用,你可以刪除所有這些文件。做好備份后刪掉重新啟動。

[root@szaliyun lib]# cp -r mysql/ mysql231029back
[root@szaliyun lib]# cd mysql
[root@szaliyun mysql]# ls
auto.cnf  binlog.index  ca-key.pem  ca.pem  client-cert.pem  client-key.pem  #innodb_redo  mysql-bin  private_key.pem  public_key.pem  server-cert.pem  server-key.pem
[root@szaliyun mysql]# rm -rf /var/lib/mysql/*
[root@szaliyun mysql]# ls
[root@szaliyun mysql]# systemctl start mysql
Failed to start mysql.service: Unit not found.
[root@szaliyun mysql]# systemctl start mysqld
[root@szaliyun mysql]# 
[root@szaliyun mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2023-10-29 16:46:32 CST; 6s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 11202 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 11369 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─11369 /usr/sbin/mysqld

1029 16:46:26 szaliyun systemd[1]: Starting MySQL Server...
1029 16:46:32 szaliyun systemd[1]: Started MySQL Server.
[root@szaliyun mysql]# 

啟動成功!

五、獲取并修改密碼

獲取臨時密碼

[root@szaliyun mysql]# grep 'temporary password' /var/log/mysqld.log
2023-10-29T08:46:29.090680Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: giAufyacf3</
[root@szaliyun mysql]# 

然后嘗試登錄

[root@szaliyun /]# mysql -u root -p
-bash: mysql: 未找到命令  
[root@szaliyun mysql]# which mysql
/usr/bin/which: no mysql in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@szaliyun mysql]#

沒有找到mysql,經(jīng)過幾番測試,還是沒找到mysql的安裝目錄,最后GPT讓我重裝。

[root@szaliyun mysql]# rpm -qa | grep mysql
mysql-community-libs-8.0.35-1.el7.x86_64
mysql-community-libs-compat-8.0.35-1.el7.x86_64
mysql-community-server-8.0.35-1.el7.x86_64
mysql-community-client-plugins-8.0.35-1.el7.x86_64
mysql-community-client-8.0.35-1.el7.x86_64
mysql80-community-release-el7-11.noarch
mysql-community-common-8.0.35-1.el7.x86_64
mysql-community-icu-data-files-8.0.35-1.el7.x86_64
[root@szaliyun mysql]# yum reinstall mysql-community-client-8.0.35-1.el7.x86_64

重裝完之后就可以了

[root@szaliyun mysql]# which mysql
/usr/bin/mysql

然后就是修改密碼:

[root@szaliyun /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.35

Copyright (c) 2000, 2023, 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> 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'New%Password4';
Query OK, 0 rows affected (0.15 sec)

mysql> 

至此修改密碼完成。

六、防火墻放行、遠程登錄和設(shè)置

放開CentOS網(wǎng)絡(luò)端口

[root@szaliyun ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@szaliyun ~]# firewall-cmd --reload

然后再在硬件防火墻上放開(如果需要),如果是使用云服務(wù)器(例如阿里云),則在云供應(yīng)商的設(shè)置頁面放開3306端口。
然后在公網(wǎng)上telnet ip 3306,端口通了。
再使用SQLyog嘗試連接數(shù)據(jù)庫,顯示 :
在CentOS上用yum方式安裝MySQL8過程記錄,Linux,系統(tǒng)管理和服務(wù)器,數(shù)據(jù)庫,centos,linux,運維,mysql

出現(xiàn)這個Host is not allowed to connect to this MySQL server很常見,就是我現(xiàn)在要連接的ip沒有授權(quán)訪問,授權(quán)就好。

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> 

繼續(xù)測試連接,報下面錯誤:

在CentOS上用yum方式安裝MySQL8過程記錄,Linux,系統(tǒng)管理和服務(wù)器,數(shù)據(jù)庫,centos,linux,運維,mysql
Plugin caching_sha2_password could not be loaded報錯
這是因為MYSQL8.0版使用了新的密碼機制。
為了方便,將密碼機制改為mysql_native_password(安全性降低了)

mysql> select Host,User,Plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host      | User             | Plugin                |
+-----------+------------------+-----------------------+
| %         | root             | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> alter user root@'%' identified with mysql_native_password by 'New#password2';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> select Host,User,Plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host      | User             | Plugin                |
+-----------+------------------+-----------------------+
| %         | root             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

mysql>

再測試連接,成功!
在CentOS上用yum方式安裝MySQL8過程記錄,Linux,系統(tǒng)管理和服務(wù)器,數(shù)據(jù)庫,centos,linux,運維,mysql

七、命令記錄

過程中敲過的一些命令:文章來源地址http://www.zghlxwxcb.cn/news/detail-722006.html

#安裝MYSQL8的yum源
[root@szaliyun ~]# yum localinstall https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm
[root@szaliyun ~]# yum repolist enabled
[root@szaliyun ~]# yum repolist enabled | grep "mysql.*-community.*" 
[root@szaliyun ~]# find / -name ib_logfile0  #查找文件
[root@szaliyun data]# mkdir ib_logfilebackup
[root@szaliyun data]# cp ib_logfile0 ib_logfilebackup/
#卸載mysql5.6
[root@szaliyun ~]# yum remove bt-mysql56-5.6.50-1.el7.x86_64
#卸載mysql-community-server
[root@szaliyun ~]# yum remove mysql-community-server-8.0.35-1.el7.x86_64
[root@szaliyun ~]# yum install mysql-community-server
[root@szaliyun ~]# systemctl start mysqld
[root@szaliyun ~]# systemctl status mysqld
[root@szaliyun ~]# cat /var/log/mysqld.log
[root@szaliyun ~]# which mysql
#重裝mysql客戶端
[root@szaliyun mysql]# yum reinstall mysql-community-client-8.0.35-1.el7.x86_64
[root@szaliyun ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@szaliyun ~]# firewall-cmd --reload
[root@szaliyun /]# mysql -u root -p
#修改密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'New%Password4';  
#放開所有地址訪問數(shù)據(jù)庫
mysql> update user set host = '%' where user = 'root';
#修改密碼規(guī)則
mysql> alter user root@'%' identified with mysql_native_password by 'New#password2'; 

到了這里,關(guān)于在CentOS上用yum方式安裝MySQL8過程記錄的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Centos7 兩種方式安裝 MySQL5.7 步驟 yum 、本地 tar 文件

    Centos7 兩種方式安裝 MySQL5.7 步驟 yum 、本地 tar 文件

    1、卸載系統(tǒng)自帶 mariadb MariaDB Server 是最流行的開源 關(guān)系型數(shù)據(jù)庫 之一。它由 MySQL 的原始開發(fā)者制作,并保證保持開源。 在 CentOS 7 中默認安裝有 MariaDB 可忽略,安裝完成之后可以直接覆蓋掉 MariaDB。 查看并卸載系統(tǒng)自帶的 Mariadb 2、下載并安裝 MySQL 官方的 Yum 由于 CentOS 的

    2024年01月24日
    瀏覽(25)
  • Centos7.6 安裝mysql過程全記錄

    Centos7.6 安裝mysql過程全記錄

    在centos 7.6上 離線安裝mysql 的步驟,可參考下文: 查找之前是否安裝了MySQL rpm -qa|grep -i mysql 如果已經(jīng)安裝mysql,則需要先停止MySQL,再刪除之前安裝的MySQL ,把rpm -qa | grep mysql 得到的安裝包名XXX 寫上即 rpm -ev xxx? rpm -ev bt-mysql56-5.6.47-1.el7.x86_64 查找之前MySQL的目錄,刪除老版本

    2024年02月13日
    瀏覽(20)
  • yum安裝mysql8

    記錄一下安裝過程用于后面項目參考 一般情況下都是docker安裝,部分特殊情況下,例如老外的項目部分禁用docker,那一般二進制安裝或者yum直接安裝。 安裝操作系統(tǒng) redhat 7.x mysql版本 8.0.22 安裝方式為 yum 安裝 確保您具有管理員權(quán)限或以root用戶身份登錄到系統(tǒng) 1.運行以下命令

    2024年02月07日
    瀏覽(19)
  • Yum安裝MySQL8.0版本

    Yum安裝MySQL8.0版本

    操縱系統(tǒng):Centos7.6 IP地址:192.168.66.61 內(nèi)存:2G CPU:4C 提前關(guān)閉selinux和防火墻 配置yum源 網(wǎng)絡(luò)能夠通 1.先備份Centos-Base.repo,然后從阿里云下載centos7-repo 備份本地yum源 下載阿里云的yum源 2.安裝之前的環(huán)境檢查 在Centos7的系統(tǒng)上默認是mariadb,如果要安裝MySQL需要先把系統(tǒng)中存在的

    2024年02月08日
    瀏覽(18)
  • CentOS 安裝Mysql8

    CentOS 安裝Mysql8

    1.檢查是否已經(jīng)安裝mysql,停止mysql服務(wù),刪除mysql 2.配置倉庫 ?更新秘鑰 ?安裝mysql8的yum源 3. 安裝mysql ? 啟動mysql服務(wù)?? 4. 啟動后配置 ? ?初始化mysql密碼 效果如下圖:?? ?登錄mysql數(shù)據(jù)庫系統(tǒng) ?mysql -uroot -p 修改root初始密碼 alter user \\\'root\\\'@\\\'%\\\' identified by \\\'abc@123\\\'; 5.設(shè)置允許遠

    2024年02月15日
    瀏覽(18)
  • centos安裝mysql8

    安裝mysql-8.0.31-el7-x86_64.tar.gz包 安裝mysql-8.0.31-el7-x86_64.tar.gz包 修改mysql配置 vi /etc/my.cnf 覆蓋以下全部內(nèi)容,注意格式 初始化mysql配置 /etc/init.d/mysql.server start 修改/etc/profile文件 注釋掉/etc/my.cnf文件的skip-grant-tables 開啟skip-grant-tables 同上面的修改密碼一樣,不過得知道host域

    2024年02月12日
    瀏覽(19)
  • CentOS 8 非編譯方式 yum 安裝 FFmpeg

    CentOS 8 非編譯方式 yum 安裝 FFmpeg

    FFmpeg 是一套免費的開源計算機程序,它提供了錄制、轉(zhuǎn)換以及流化音視頻的完整解決方案。FFmpeg 在 Linux 平臺下開發(fā),但它同樣也可以在其它操作系統(tǒng)環(huán)境中編譯運行,包括 Windows、Mac OS X 等。大多數(shù)文章都是說的ubuntu上如何安裝,這里說一下centos8下面如何安裝。 為在 Cent

    2024年02月13日
    瀏覽(22)
  • centos安裝MySQL8完整指南

    目錄 1. 卸載mariadb 2. 下載 3. 安裝 4. 若安裝失敗、卸載、重新安裝 5. 啟動 6. 修改密碼 ?7. 設(shè)置mysql遠程鏈接 因centos7默認安裝了mariadb, 會造成依賴沖突,按下列方式進行卸載: ? 這個數(shù)據(jù)源不能用了,我將下載后文件放在了我的資源里。如果還是get不到可以私信我,我看見的

    2023年04月15日
    瀏覽(21)
  • centos7安裝MySQL8

    centos7安裝MySQL8

    Centos7安裝MySQL8 MySQL版本:8.0.34 1.安裝前準備 (1)查看是否安裝mariadb [root@kb135 ~]# rpm -qa|grep mariadb (2)卸載mariadb并檢查是否卸干凈 [root@kb135 ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 2.安裝mysql (1)將安裝包復(fù)制到/opt/software文件夾下 (2)解壓文件至/usr/local目錄下 [root@kb135

    2024年02月11日
    瀏覽(26)
  • centos docker安裝mysql8

    1、創(chuàng)建掛載文件夾 mkdir -p /mydata/mysql/log mkdir -p /mydata/mysql/data mkdir -p /mydata/mysql/conf 2、拉取鏡像最新版本,如果寫?mysql:8.0.26可以指定版本 docker pull mysql 3、啟動命令 docker run -p 3306:3306 --restart=always -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/my

    2024年02月07日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包