需要将在Windows上的mysql-5.7.35升级为mysql-5.7.39,除了将数据导出后再导入新版本的升级方法,还可以使用mysql_upgrade方法直接升级版本,并且mysql数据较为复杂的情况下更为适用。
升级过程操作方法注意老的mysql的环境变量要修改
关闭应用关闭数据库老数据库信息
C:\Users\admin>d:
D:\>cd mysql-5.7.35-winx64
D:\mysql-5.7.35-winx64>cd bin
D:\mysql-5.7.35-winx64\bin>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1845
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql>
解压新数据库软件并移动数据将新mysql软件解压到同一目录下
要将my.ini中的相应内容进行修改,例如basedir,datadir
移除老的mysql服务管理员启动cmd,进入mysql的bin目录,注意先将mysql服务停止
C:\Windows\system32>d:
D:\>cd mysql-5.7.35-winx64
D:\mysql-5.7.35-winx64>cd bin
D:\mysql-5.7.35-winx64\bin>mysqld --remove MySQL
Failed to remove the service because the service is running
Stop the service and try again
D:\mysql-5.7.35-winx64\bin>mysqld --remove MySQL
Service 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-winx64
D:\mysql-5.7.39-winx64>cd bin
D:\mysql-5.7.39-winx64\bin>mysqld --install mysql5.7
Service successfully installed.
启动新的mysql服务
D:\mysql-5.7.39-winx64\bin>net start mysql5.7
mysql5.7 服务正在启动 .
mysql5.7 服务已经启动成功。
更新mysql
密码是使用老的mysql密码
D:\mysql-5.7.39-winx64\bin>mysql_upgrade -uroot -p
Enter password: **********
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
。。。。。。。。。
iplat.xs_user_ext OK
iplat.xs_user_group OK
iplat.xs_user_group_member OK
sys.sys_config OK
Upgrade process completed successfully.
Checking if update is needed.
进入新的mysql中检查
D:\mysql-5.7.39-winx64\bin>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.
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)