如何通過網絡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 #查詢已安裝的軟
yum list installed|grep package #查詢具體某軟件是否安裝
安裝軟件
yum install packageName #在線安裝軟件包
yum localinstall packageName.rpm #本地安裝
更新軟件
yum list updates #列出可更新升級的軟件
yum update package_name #更新軟件
卸載軟件
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,輕輕松松一個命令搞定!
接下來就可以使用Mysql啦!
安裝好後,查看緩存目錄/var/cache/yum下的文件,可以查看到get的rpm包。
參考資料:
《Linux系統命令及Shell腳本實踐指南》
《Linux命令行與shell腳本編程大全》
本文出自 “樂學園” 博客,請務必保留此出處http://2338053.blog.51cto.com/2328053/1969853
如何通過網絡yum源安裝Mysql