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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

转载于:https://www.cnblogs.com/lzcys8868/p/7867487.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值