zoukankan      html  css  js  c++  java
  • yum 安装 mysql5.5 mysql 5.6 mysql5.7

     
    一. yum 安装mysql5.6
    1. 安装仓库
    要使用yum 安装mysql,需要使用mysql的yum 仓库,先从官网下载适合你的系统仓库
     
    然后安装一下这个仓库列表
    wget http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
    rpm -ivh mysql57-community-release-el6-5.noarch.rpm
     
     
    2.选择版本
    查看可安装的mysql版本
    [root@www ~]# yum repolist enabled | grep "mysql.*-community.*"
     
    如果我们要选择版本,可以先执行下面命令查看一下有哪些版本
    [root@www ~]# yum repolist all | grep mysql
     
    选择版本启动5.6版本的,禁用5.7版本仓库
    [root@www ~]# yum-config-manager --enable mysql56-community
    [root@www ~]# yum-config-manager --disable mysql57-community
     
    或者直接在yum 仓库中禁用mysql5.7的
    编辑/etc/yum.repos.d/mysql-community.repo文件
    enabled=0 表示禁用
    比如要安装5.7版本的mysql,要确定5.6的enabled=0,5.7的enabled=1,一次保证只启用一个子仓库
     
    [root@www yum.repos.d]# vim mysql-community.repo
    ###mysql5.5 全部禁用
    15 # Enable to use MySQL 5.5
    16 [mysql55-community]
    17 name=MySQL 5.5 Community Server
    18 baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
    19 enabled=0
    20 gpgcheck=1
    21 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
     
    ###开启mysql5.6
    23 # Enable to use MySQL 5.6
    24 [mysql56-community]
    25 name=MySQL 5.6 Community Server
    26 baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
    27 enabled=1
    28 gpgcheck=0
    29 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
     
    ###mysql5.7 禁用
    31 [mysql57-community]
    32 name=MySQL 5.7 Community Server
    33 baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
    34 enabled=0
    35 gpgcheck=1
    36 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
     
     
    这时在查看可安装mysql版本,只剩下mysql5.6
    [root@www yum.repos.d]# yum repolist enabled | grep "mysql.*-community.*"
    mysql-connectors-community MySQL Connectors Community 42
    mysql-tools-community MySQL Tools Community 51
    mysql56-community MySQL 5.6 Community Server 396
     
     
    安装mysql5.6
    [root@www yum.repos.d]# yum install mysql-community-server
     
    启动mysql数据库
    [root@www yum.repos.d]# service mysqld start
    MySQL Daemon failed to start.
    启动报错,mysql Daemon 进程启动失败,查看错误日志: /var/log/mysqld.log
    [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
    2017-11-20 00:00:20 5464 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
    2017-11-20 00:00:20 5464 [ERROR] Plugin 'InnoDB' init function returned error.
    2017-11-20 00:00:20 5464 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    2017-11-20 00:00:20 5464 [ERROR] Unknown/unsupported storage engine: InnoDB
    2017-11-20 00:00:20 5464 [ERROR] Aborting
     
    解决方法: yum安装mysql5.6 数据目录位置:/var/lib/mysql
    在此目录下删除: ibdata1 ib_logfile1 ib_logfile0 这三个目录,重启动mysql成功
     
     
    更改mysql root 密码:
    [root@www mysql]# mysqladmin -u root password '123123'
    Warning: Using a password on the command line interface can be insecure.
    mysqladmin: unable to change password; error: 'Column count of mysql.user is wrong. Expected 43, found 39. Created with MySQL 50171, now running 50638. Please use mysql_upgrade to fix this error.'
    报错信息:依据提示 执行。
    [root@www mysql]# mysql_upgrade
    再次更改mysql密码成功
    [root@www mysql]# mysqladmin -uroot password '123123'
    Warning: Using a password on the command line interface can be insecure.
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    mybatis中mysql转义讲解
    mybatis结合mysql批量操作及查询sql
    转载:避免重复插入,更新的sql
    maven下载jar包下载不下来的解决方法
    catalina.home与 catalina.base区别
    ON DUPLICATE KEY UPDATE单个增加更新及批量增加更新的sql
    普通索引的建立及普通索引的排序
    复合索引的优点和注意事项
    com.mysql.jdbc.PacketTooBigException,及mysql 设置 max_allow_packet
    ./和../和/三种路径的区别
  • 原文地址:https://www.cnblogs.com/lzcys8868/p/7867487.html
Copyright © 2011-2022 走看看