mysql版本升级

发布时间: 2023-11-21 10:36 阅读: 文章来源:1MUMB65PS
背景

需要将在Windows上的mysql-5.7.35升级为mysql-5.7.39,除了将数据导出后再导入新版本的升级方法,还可以使用mysql_upgrade方法直接升级版本,并且mysql数据较为复杂的情况下更为适用。

升级过程操作方法

注意老的mysql的环境变量要修改

关闭应用关闭数据库

老数据库信息

C:\Users\admin>d:D:\>cd mysql-5.7.35-winx64D:\mysql-5.7.35-winx64>cd binD:\mysql-5.7.35-winx64\bin>mysql -u root -pEnter password: **********Welcome to the MySQL monitor.Commands end with ; or \g.Your MySQL connection id is 1845Server version: 5.7.35 MySQL Community Server (GPL)Copyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>mysql>解压新数据库软件并移动数据将新mysql软件解压到同一目录下

拷贝my.ini和data文件夹

要将my.ini中的相应内容进行修改,例如basedir,datadir

移除老的mysql服务

管理员启动cmd,进入mysql的bin目录,注意先将mysql服务停止

C:\Windows\system32>d:D:\>cd mysql-5.7.35-winx64D:\mysql-5.7.35-winx64>cd binD:\mysql-5.7.35-winx64\bin>mysqld --remove MySQLFailed to remove the service because the service is runningStop the service and try againD:\mysql-5.7.35-winx64\bin>mysqld --remove MySQLService successfully removed.安装并启动新的mysql服务

安装新的mysql服务

D:\mysql-5.7.35-winx64\bin>cd ../D:\mysql-5.7.35-winx64>cd ../D:\>cd mysql-5.7.39-winx64D:\mysql-5.7.39-winx64>cd binD:\mysql-5.7.39-winx64\bin>mysqld --install mysql5.7Service successfully installed.

启动新的mysql服务

D:\mysql-5.7.39-winx64\bin>net start mysql5.7mysql5.7 服务正在启动 .mysql5.7 服务已经启动成功。更新mysql

密码是使用老的mysql密码

D:\mysql-5.7.39-winx64\bin>mysql_upgrade -uroot -pEnter password: **********Checking if update is needed.Checking server version.Running queries to upgrade MySQL server.Checking system database.mysql.columns_priv OKmysql.dbOKmysql.engine_costOK。。。。。。。。。iplat.xs_user_extOKiplat.xs_user_groupOKiplat.xs_user_group_member OKsys.sys_config OKUpgrade process completed successfully.Checking if update is needed.进入新的mysql中检查D:\mysql-5.7.39-winx64\bin>mysql -u root -pEnter password: **********Welcome to the MySQL monitor.Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.7.39 MySQL Community Server (GPL)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>mysql>mysql> show databases;+--------------------+| Database|+--------------------+| information_schema || act|| mysql|| performance_schema || sys|+--------------------+9 rows in set (0.00 sec)5 rows in set (0.00 sec)
•••展开全文