如何通過網路yum源安裝Mysql

來源:互聯網
上載者:User

標籤:yum mysql

    近日想在本地搭建Mysql的環境,準備工作和安裝過程如下:


1.  軟體環境:

CentOS 7

Mysql 5.6


2.  linux環境安裝方式比較:

安裝方式 優點 缺點
源碼包編譯安裝
  • 可量身定製軟體的功能模組;
  • 源碼編譯選擇性參數多,易出錯;

  • 編譯安裝過程耗時較長;

  • 不具備軟體管理功能;

RPM安裝(Redhat Package Manager)
  • 提供軟體管理功能,安裝、升級、卸載;

  • 操作方便、快捷;

  • 包間依賴;
yum安裝(Yellow dog Updater,Modified)
  • 支援線上、離線兩種方式;

  • 自動解決依賴關係;



3. yum介紹

    在開始安裝之前,先來瞭解下yum的常用命令和相關的配置。

3.1 yum常用命令

  • 查詢軟體安裝情況

yum list installed   #查詢已安裝的軟650) this.width=650;" src="https://s1.51cto.com/wyfs02/M02/A6/66/wKioL1nN8tHiaIKoAAEKzPAWXgA916.png" title="yum list installed.png" alt="wKioL1nN8tHiaIKoAAEKzPAWXgA916.png" />

     

      yum list installed|grep package  #查詢具體某軟體是否安裝650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/07/B4/wKiom1nN9HPSTFJLAAAyQIq9j6o619.png" title="yum list installed grep.png" alt="wKiom1nN9HPSTFJLAAAyQIq9j6o619.png" />

    

  • 安裝軟體

    yum install packageName  #線上安裝軟體包

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M01/A6/66/wKioL1nN90Ox5nkcAACWcEHAjzk376.png" title="yum install rabbimq.png" alt="wKioL1nN90Ox5nkcAACWcEHAjzk376.png" />


        yum localinstall packageName.rpm  #本地安裝

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/07/B5/wKiom1nN96WxzrmrAAAddbbrrlw224.png" title="yum localinstall.png" alt="wKiom1nN96WxzrmrAAAddbbrrlw224.png" />


  •     更新軟體

    yum list updates #列出可更新升級的軟體

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/07/B9/wKiom1nOL8vDr9q7AAEPqLrfr2c980.png" title="yum list update (2).png" alt="wKiom1nOL8vDr9q7AAEPqLrfr2c980.png" />

    

    yum update package_name  #更新軟體

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/A6/6A/wKioL1nOL22z-ZarAADcCzLCB6c721.png" title="yum update python.png" alt="wKioL1nOL22z-ZarAADcCzLCB6c721.png" />


  • 卸載軟體

    yum remove package_name  #只刪除軟體包,保留設定檔和資料檔案;

       yum erase package_name  #刪除軟體和它所有的檔案。


3.2 建立網路yum源

    要搭建yum源,需要先瞭解以下設定檔和相關目錄。

    /etc/yum.conf          #yum的設定檔,配置緩衝路徑,日誌路徑和gpg檢查

    /etc/yum.repos.d/    #自訂的倉庫

    /var/log/yum.log      #yum日誌

    /var/cache/yum/       #儲存下載的rpm包


    yum.conf設定檔,主要分為兩部分,[main]部分配置全域變數;第二部分,用於配置倉程式庫伺服器,這部分也可以在/etc/yum.repos.d/目錄下,儲存為.repo的檔案進行配置。

以下資訊為/etc/yum.conf內容:

[[email protected] etc]# nl yum.conf 

     1  [main]

     2  cachedir=/var/cache/yum/$basearch/$releasever

     3  keepcache=0

     4  debuglevel=2

     5  logfile=/var/log/yum.log

     6  exactarch=1

     7  obsoletes=1

     8  gpgcheck=1

     9  plugins=1

    10installonly_limit=5

    11bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum

    12distroverpkg=centos-release

    13#  This is the default, if you make this bigger yum won‘t see if the metadata

    14# is newer on the remote and so you‘ll "gain" the bandwidth of not having to

    15# download the new metadata and "pay" for it by yum not having correct

    16# information.

    17#  It is esp. important, to have correct metadata, for distributions like

    18# Fedora which don‘t keep old packages around. If you don‘t like this checking

    19# interupting your command line usage, it‘s much better to have something

    20# manually check the metadata once an hour (yum-updatesd will do this).

    21# metadata_expire=90m

    22# PUT YOUR REPOS HERE OR IN separate files named file.repo

    23# in /etc/yum.repos.d


    在瞭解了以上知識後,開始著手建立Mysql的倉庫檔案。

cd  /etc/yum.repos.d/

touch mysql-community.repo

vi mysql-community.repo


在該檔案中添加以下資訊:

#Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

enabled=1   #0為關閉yum源,1為開啟yum源

gpgcheck=0   #0為不需要驗證軟體包,1為需要驗證軟體包

gpgkey=


4.  安裝Mysql

    配好了repository,也知道了yum的命令,就可以安裝啦!

    簡單的執行yum install mysql,輕輕鬆鬆一個命令搞定!

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/07/BB/wKiom1nOVGjQNXw2AAEUaGn6LFQ894.png" title="yum install mysql (2).png" alt="wKiom1nOVGjQNXw2AAEUaGn6LFQ894.png" />

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/A6/6D/wKioL1nOVLaRSG5XAACuj-j98II402.png" title="installed.png" alt="wKioL1nOVLaRSG5XAACuj-j98II402.png" />    接下來就可以使用Mysql啦!


    安裝好後,查看緩衝目錄/var/cache/yum下的檔案,可以查看到get的rpm包。

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M01/A6/6C/wKioL1nOTcrzuOtrAAA76MwbS7U666.png" title="cache file.png" alt="wKioL1nOTcrzuOtrAAA76MwbS7U666.png" />


參考資料:

《Linux系統命令及Shell指令碼實踐指南》

《Linux命令列與shell指令碼編程大全》



本文出自 “樂學園” 部落格,請務必保留此出處http://2338053.blog.51cto.com/2328053/1969853

如何通過網路yum源安裝Mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.