CentOS下MysqL5.6升级5.7指南
前提你的MysqL是通过yum安装,其他情况没有测试
Step 0.
检查是否是 yum安装的MysqL
yum list installed | grep MysqL
Step 1.
删除通过yum安装的 MysqL
yum -y remove MysqL-libs.x86_64 yum -y remove MysqL-*
Step 2.
更新yum源
以下
MysqL-community-release-el6-5.noarch.rpm
镜像源根据实际情况下载 查看yum源
# 下载镜像源 wget dev.MysqL.com/get/MysqL-community-release-el6-5.noarch.rpm # 本地配置镜像源 yum localinstall MysqL-community-release-el6-5.noarch.rpm # 查看本地镜像源是否生效 yum repolist all | grep MysqL
看到的应该是这样的
MysqL-connectors-community/x86_64 MysqL Connectors Community 启用: 30 MysqL-connectors-community-source MysqL Connectors Community - Sourc 禁用 MysqL-tools-community/x86_64 MysqL Tools Community 启用: 40 MysqL-tools-community-source MysqL Tools Community - Source 禁用 MysqL55-community/x86_64 MysqL 5.5 Community Server 禁用 MysqL55-community-source MysqL 5.5 Community Server - Sourc 禁用 MysqL56-community/x86_64 MysqL 5.6 Community Server 禁用 MysqL56-community-source MysqL 5.6 Community Server - Sourc 禁用 MysqL57-community-dmr/x86_64 MysqL 5.7 Community Server Develop 启用: 164 MysqL57-community-dmr-source MysqL 5.7 Community Server Develop 禁用
# 禁用 MysqL 5.5和5.6的源 yum-config-manager --disable MysqL55-community yum-config-manager --disable MysqL56-community # 启用 MysqL 5.7的源 yum-config-manager --enable MysqL57-community-dmr # 查看是否生效 yum repolist enabled | grep MysqL
看到的应该是这样的
MysqL-connectors-community/x86_64 MysqL Connectors Community 30 MysqL-tools-community/x86_64 MysqL Tools Community 40 MysqL57-community-dmr/x86_64 MysqL 5.7 Community Server Development M 164
Step 3.
安装 MysqL server
# 安装 yum install MysqL-community-server # 启动 service MysqLd start
Step 4.
安装完成,更新相关配置
# 停掉 MysqL service MysqLd stop # 启动安全模式 MysqLd_safe --skip-grant-tables # 在新的终端登录MysqL MysqL
# 切换数据库 MysqL> use MysqL; # 更新密码 MysqL> UPDATE user SET authentication_string=PASSWORD('新密码') WHERE User='root'; # 刷新权限 MysqL> flush privileges; # 退出登录 MysqL> exit;
重新启动MysqL
service MysqLd start
如果在以上几步之后依然无法登录,并且提示:
Table 'performance_schema.session_variables' doesn't exist
错误,你可以更新MysqL结构,然后重复以上Step4步骤即可,操作如下
MysqL_upgrade -u root -p --force