一:查看下是否有系统自带MySQL的rpm包,如果有,需要删除自带的旧rpm包。
[root@localhost mnt]# mysql -V mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 [root@localhost mnt]# rpm -qa | grep -i mysql mysql-server-5.1.73-8.el6_8.x86_64 mysql-5.1.73-8.el6_8.x86_64 mysql-devel-5.1.73-8.el6_8.x86_64 mysql-libs-5.1.73-8.el6_8.x86_64 perl-DBD-MySQL-4.013-3.el6.x86_64 [root@localhost mnt]# yum remove mysql*
二:在MySQL官网下载安装MySQL-5.6.21所需的rpm软件包。
需要下载三个rpm软件包:
MySQL-client-5.6.21-1.rhel5.x86_64.rpm
MySQL-devel-5.6.21-1.rhel5.x86_64.rpm
MySQL-server-5.6.21-1.rhel5.x86_64.rpm
[root@linuxidc /mnt]#wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm [root@linuxidc /mnt]#wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm [root@linuxidc /mnt]#wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm
报错:
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm --2017-09-14 17:07:49-- http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm 正在解析主机 dev.mysql.com... 137.254.60.11 正在连接 dev.mysql.com|137.254.60.11|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 301 Moved Permanently 位置:https://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm [跟随至新的 URL] --2017-09-14 17:07:50-- https://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm 正在连接 dev.mysql.com|137.254.60.11|:443... 已连接。 错误: 证书通用名 “www.mysql.com” 与所要求的主机名 “dev.mysql.com” 不符。 要以不安全的方式连接至 dev.mysql.com,使用‘--no-check-certificate’。
所以添加提示参数:
[root@linuxidc /mnt]#wget --no-check-certificate http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm [root@linuxidc /mnt]#wget --no-check-certificate http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm [root@linuxidc /mnt]#wget --no-check-certificate http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm
三:启动mysql,报错
[root@localhost opt]# service mysql restart ERROR! MySQL server PID file could not be found! Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.pid).
本次解决方法:
cd /var/lib/mysql
rm -rf ibdata1 ib_logfile1 ib_logfile0
此时:
service mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!
根据http://www.jb51.net/article/48625.htm博文,也有其他解决方案
原文地址:http://11787464.blog.51cto.com/11777464/1965384