温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何通过网络yum源安装Mysql

发布时间:2020-08-06 14:39:24 来源:网络 阅读:502 作者:ilanqing 栏目:软件技术

    近日想在本地搭建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源安装Mysql

     

      yum list installed|grep package  #查询具体某软件是否安装如何通过网络yum源安装Mysql

    

  • 安装软件

    yum install packageName  #在线安装软件包

如何通过网络yum源安装Mysql


        yum localinstall packageName.rpm  #本地安装

如何通过网络yum源安装Mysql


  •     更新软件

    yum list updates #列出可更新升级的软件

如何通过网络yum源安装Mysql

    

    yum update package_name  #更新软件

如何通过网络yum源安装Mysql


  • 卸载软件

    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内容:

[root@Durian 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,轻轻松松一个命令搞定!

如何通过网络yum源安装Mysql

如何通过网络yum源安装Mysql    接下来就可以使用Mysql啦!


    安装好后,查看缓存目录/var/cache/yum下的文件,可以查看到get的rpm包。

如何通过网络yum源安装Mysql


参考资料:

《Linux系统命令及Shell脚本实践指南》

《Linux命令行与shell脚本编程大全》



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI