yum 安装 mysql5.5 mysql 5.6 mysql5.7
Posted 刘振川的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 mysql-community-release-el6-5.noarch.rpm
或: # yum install http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
2.选择版本
查看可安装的mysql版本
[[email protected] ~]# yum repolist enabled | grep "mysql.*-community.*"
如果我们要选择版本,可以先执行下面命令查看一下有哪些版本
[[email protected] ~]# yum repolist all | grep mysql
选择版本启动5.6版本的,禁用5.7版本仓库
[[email protected] ~]# yum-config-manager --enable mysql56-community [[email protected] ~]# 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,一次保证只启用一个子仓库
[[email protected] 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
[[email protected] 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
[[email protected] yum.repos.d]# yum install mysql-community-server
启动mysql数据库
[[email protected] 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 密码:
[[email protected] 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.‘
报错信息:依据提示 执行。
[[email protected] mysql]# mysql_upgrade
再次更改mysql密码成功
[[email protected] mysql]# mysqladmin -uroot password ‘123123‘
Warning: Using a password on the command line interface can be insecure.
以上是关于yum 安装 mysql5.5 mysql 5.6 mysql5.7的主要内容,如果未能解决你的问题,请参考以下文章