zoukankan      html  css  js  c++  java
  • Centos 7 安装 Mysql 5.5 5.6 5.7

    环境

    [root@node1 ~]#  cat /etc/redhat-release
    CentOS Linux release 7.1.1503 (Core)
    [root@node1 ~]# uname -a
    Linux node4 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    检查系统是否自带安装mysql

    [root@node1 ~]# yum list installed | grep mysql 
    [root@node1 ~]# 

    如果有将其删除

    [root@node1 ~]# yum -y remove mysql-libs.x86_64
    Loaded plugins: fastestmirror
    No Match for argument: mysql-libs.x86_64
    No Packages marked for removal

    由于mysql的yum源服务器在国外,所以下载速度会比较慢,还好mysql5.6只有79M大,而mysql5.7就有182M了,所以这里想安装mysql5.6

    下载rpm包

    [root@node1 ~]# wget http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm

    解压

    [root@node1 ~]# rpm -ivh mysql-community-release-el7-7.noarch.rpm 

    检查mysql源是否安装成功

    [root@node2 ~]# yum repolist enabled | grep "mysql.*-community.*"
    mysql-connectors-community/x86_64 MySQL Connectors Community                  42
    mysql-tools-community/x86_64      MySQL Tools Community                       51
    mysql56-community/x86_64          MySQL 5.6 Community Server              

    查看是否已经有mysql可安装文件

    root@node1 ~]#  yum repolist all | grep mysql
    mysql-connectors-community/x86_64 MySQL Connectors Community     enabled:     42
    mysql-connectors-community-source MySQL Connectors Community - S disabled
    mysql-tools-community/x86_64      MySQL Tools Community          enabled:     51
    mysql-tools-community-source      MySQL Tools Community - Source disabled
    mysql55-community/x86_64          MySQL 5.5 Community Server     disabled
    mysql55-community-source          MySQL 5.5 Community Server - S disabled
    mysql56-community/x86_64          MySQL 5.6 Community Server     enabled:    344
    mysql56-community-source          MySQL 5.6 Community Server - S disabled
    mysql57-community/x86_64          MySQL 5.7 Community Server     disabled
    mysql57-community-source          MySQL 5.7 Community Server - S disabled

    可以修改 mysql-community.repo 源,更改默认安装的mysql版本比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示: 

    [root@node2 ~]# vim /etc/yum.repos.d/mysql-community.repo
    
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    [mysql-tools-community]
    name=MySQL Tools Community
    baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    # Enable to use MySQL 5.5
    [mysql55-community]
    name=MySQL 5.5 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    # 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/7/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    [mysql57-community]
    name=MySQL 5.7 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

    安装mysql 服务器(网速决定安装速度)

    [root@node1 ~]# yum -y install mysql-community-server

    启动 mysql 服务

    [root@node1 ~]# systemctl start mysql

    查看mysql 的启动状态

    [root@node1 ~]# systemctl status mysqld
    mysqld.service - MySQL Community Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
       Active: active (running) since Wed 2017-08-23 11:28:23 EDT; 38min ago
      Process: 2904 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
      Process: 2843 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
     Main PID: 2903 (mysqld_safe)

    开机启动

    [root@node1 ~]# systemctl enable mysqld
    [root@node1 ~]# systemctl daemon-reload
  • 相关阅读:
    剑指Offer-46.孩子们的游戏(圆圈中最后剩下的数)(C++/Java)
    剑指Offer-45.扑克牌顺子(C++/Java)
    剑指Offer-44.翻转单词顺序列(C++/Java)
    剑指Offer-43.左旋转字符串(C++/Java)
    剑指Offer-42.和为S的两个数字(C++/Java)
    剑指Offer-41.和为S的连续正数序列(C++/Java)
    剑指Offer-40.数组中只出现一次的数字(C++/Java)
    剑指Offer-39.把数组排成最小的数(C++/Java)
    Codeforces Round #316 (Div. 2) D Tree Requests
    URAL 1774 Barber of the Army of Mages (最大流)
  • 原文地址:https://www.cnblogs.com/wanglan/p/7418438.html
Copyright © 2011-2022 走看看