400-650-7353
您所在的位置:首頁(yè) > IT干貨資料 > linux > 【Linux基礎(chǔ)知識(shí)】CentOS7安裝MySQL8.0 rpm包

【Linux基礎(chǔ)知識(shí)】CentOS7安裝MySQL8.0 rpm包

  • 來源:Linux干貨資料
  • 2021-03-22 16:01:16
  • 閱讀()
  • 分享
  • 手機(jī)端入口

MySQL數(shù)據(jù)庫(kù)簡(jiǎn)介

MySQL早期由瑞典的MySQL AB開發(fā)與推廣,后來先后被SUN和Oracle公司所收購(gòu),成為當(dāng)今最流行的開源數(shù)據(jù)庫(kù)。與其他商用數(shù)據(jù)庫(kù)比較,MySQL在功能上存在一定程度的不足,但是這并不影響其受歡迎的程度。因?yàn)榛竟δ軌蛴枚议_源免費(fèi),可以大大降低運(yùn)營(yíng)成本,所以MySQL在世界范圍內(nèi)的大中小型企業(yè)中得到了廣泛的應(yīng)用。MySQL主要用于存儲(chǔ)業(yè)務(wù)過程中產(chǎn)生的各類業(yè)務(wù)數(shù)據(jù)。

CentOS 7上MySQL 8.0 rpm包安裝

(1)前提條件

假設(shè)當(dāng)前CentOS 7已經(jīng)配置好了網(wǎng)絡(luò)或本地yum源,考慮到安全穩(wěn)定性,通常作為服務(wù)器用的Linux普遍采用最小安裝方式,即只安裝必須要用的軟件包,這樣可以節(jié)約系統(tǒng)資源和降低不需要的應(yīng)用程序所攜帶的潛在安全風(fēng)險(xiǎn)。MySQL8.0軟件的安裝過程需要用到諸如Perl語(yǔ)言等的一些相關(guān)軟件包。

(2)下載針對(duì)CentOS 7的MySQL 8.0 rpm包

下載MySQL的網(wǎng)址是https://www.mysql.com/downloads/,進(jìn)入頁(yè)面后單擊MySQL社區(qū)版鏈接,如下圖所示。

進(jìn)入頁(yè)面后單擊“MySQL Community Server”,如下圖所示。

進(jìn)入頁(yè)面后,操作系統(tǒng)選擇“Red Hat Enterprice Linux/Oracle Linux”,操作系統(tǒng)版本選擇“Red Hat Enterprice Linux 7/Oracle Linux 7 (x86,64-bit)”,如下圖所示。

在當(dāng)前頁(yè)面下方可以看到MySQL 8.0對(duì)應(yīng)的“rpm bundle”下載鏈接,單擊“Download”即可,如下圖所示。

頁(yè)面跳轉(zhuǎn)到如下圖所示頁(yè)面,單擊“No thanks, just start my download.”,即可開始下載MySQL 8.0 rpm包安裝程序。

(3)安裝步驟

①輸入setenforce 0,禁用selinux。通常MySQL運(yùn)行時(shí)需要禁用selinux功能,否則可能會(huì)影響MySQL數(shù)據(jù)庫(kù)服務(wù)的正常運(yùn)行。

②上傳MySQL軟件包到CentOS 7系統(tǒng)。通常使用root用戶操作,使用rz命令,將MySQL 8.0 rpm軟件安裝包mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar上傳到CentOS 7的/root目錄中。

③輸入tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar,還原安裝包中的rpm包。

④輸入yum install mysql-community-{libs,client,common,server}-*.rpm,安裝軟件。

⑤輸入systemctl start mysqld,啟動(dòng)mysql數(shù)據(jù)庫(kù)初始化。

(4)首次登錄準(zhǔn)備工作

至此,MySQL的軟件已經(jīng)安裝完畢,然后需要啟動(dòng)MySQL服務(wù),進(jìn)行數(shù)據(jù)文件的初始化工作,步驟如下:

①輸入grep -i "temporary password" /var/log/mysqld.log,抓取臨時(shí)登錄密碼。

②運(yùn)行mysql_secure_installation初始化MySQL,會(huì)有交互式的輸出如下,參見中文的注釋內(nèi)容:

[root@CentOS7-7 bin]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 輸入臨時(shí)登錄密碼

The 'validate_password' component is installed on the server.

The subsequent steps will run with the existing configuration

of the component.

Using existing password for root.

Estimated strength of the password: 100

Change the password for root ? ((Press y|Y for Yes, any other key for No) : y 改變r(jià)oot密碼選“y”

New password: 輸入新密碼,要求不少于8位,包括大寫字母、小寫字母、數(shù)字和特殊符號(hào)

Re-enter new password: 重新輸入新密碼

Estimated strength of the password: 100

#是否繼續(xù)使用新的密碼,選“y”

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving a production

environment.

# 去除匿名用戶嗎?選“y”

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

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

# 不允許root用戶遠(yuǎn)程登錄?選“y”

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

Success.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving a production

environment.

#刪除test數(shù)據(jù)庫(kù)嗎?選“y”

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

- Dropping test database...

Success.

- Removing privileges on test database...

Success.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

# 重新加載授權(quán)表到內(nèi)存,選“y”

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

Success.

# 至此成功初始化用戶

All done!

[root@CentOS7-7 bin]#

③輸入mysql -uroot -p,然后輸入新的密碼,連接MySQL數(shù)據(jù)庫(kù)。成功登錄MySQL數(shù)據(jù)庫(kù)后,如下圖所示,可以使用select version();語(yǔ)句查看MySQL版本號(hào)。

文章“【Linux基礎(chǔ)知識(shí)】CentOS7安裝MySQL8.0 rpm包”已幫助

>>本文地址:http://nfbqydst.cn/zhuanye/2021/68018.html

THE END  

聲明:本站稿件版權(quán)均屬中公教育優(yōu)就業(yè)所有,未經(jīng)許可不得擅自轉(zhuǎn)載。

1 您的年齡

2 您的學(xué)歷

3 您更想做哪個(gè)方向的工作?

獲取測(cè)試結(jié)果
  • 大前端大前端
  • 大數(shù)據(jù)大數(shù)據(jù)
  • 互聯(lián)網(wǎng)營(yíng)銷互聯(lián)網(wǎng)營(yíng)銷
  • JavaJava
  • Linux云計(jì)算Linux
  • Python+人工智能Python
  • 嵌入式物聯(lián)網(wǎng)嵌入式
  • 全域電商運(yùn)營(yíng)全域電商運(yùn)營(yíng)
  • 軟件測(cè)試軟件測(cè)試
  • 室內(nèi)設(shè)計(jì)室內(nèi)設(shè)計(jì)
  • 平面設(shè)計(jì)平面設(shè)計(jì)
  • 電商設(shè)計(jì)電商設(shè)計(jì)
  • 網(wǎng)頁(yè)設(shè)計(jì)網(wǎng)頁(yè)設(shè)計(jì)
  • 全鏈路UI/UE設(shè)計(jì)UI設(shè)計(jì)
  • VR/AR游戲開發(fā)VR/AR
  • 網(wǎng)絡(luò)安全網(wǎng)絡(luò)安全
  • 新媒體與短視頻運(yùn)營(yíng)新媒體
  • 直播帶貨直播帶貨
  • 智能機(jī)器人軟件開發(fā)智能機(jī)器人
 

快速通道fast track

近期開班時(shí)間TIME