windows mysql 5.1 与 8.0版本共存问题解决方案

缘起:某个产品A用到旧版本的mysql 5.1,且数据量较大。产品B用到8.0的mysql的新特性。在一台电脑上需要运行A或B,所以需要使得两个版本能够按需要进行切换。

分析:mysql作为服务程序,服务器依赖注册表,因此通过分析mysql不同版本的注册表得出下面的方案。

1.将5.1版本的注册表备份

2.将8.0版本的注册表备份

mysql 高版本和低版本的数据文件不同,因此可以同时保留在系统磁盘里,通过切换对应版本的注册信息来实现mysql的版本切换。

5.1

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MySQL]
"DisplayName"="MySQL"
"WOW64"=dword:0000014c
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\
  6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,\
  00,5c,00,4d,00,79,00,53,00,51,00,4c,00,5c,00,4d,00,79,00,53,00,51,00,4c,00,\
  20,00,53,00,65,00,72,00,76,00,65,00,72,00,20,00,35,00,2e,00,31,00,5c,00,62,\
  00,69,00,6e,00,5c,00,6d,00,79,00,73,00,71,00,6c,00,64,00,22,00,20,00,2d,00,\
  2d,00,64,00,65,00,66,00,61,00,75,00,6c,00,74,00,73,00,2d,00,66,00,69,00,6c,\
  00,65,00,3d,00,22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\
  6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,\
  00,5c,00,4d,00,79,00,53,00,51,00,4c,00,5c,00,4d,00,79,00,53,00,51,00,4c,00,\
  20,00,53,00,65,00,72,00,76,00,65,00,72,00,20,00,35,00,2e,00,31,00,5c,00,6d,\
  00,79,00,2e,00,69,00,6e,00,69,00,22,00,20,00,4d,00,79,00,53,00,51,00,4c,00,\
  00,00
"ObjectName"="LocalSystem"

8.0

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MySQL]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\
  6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,20,00,28,00,78,00,38,00,36,00,29,\
  00,5c,00,4d,00,79,00,53,00,51,00,4c,00,5c,00,6d,00,79,00,73,00,71,00,6c,00,\
  2d,00,38,00,2e,00,30,00,2e,00,33,00,31,00,2d,00,77,00,69,00,6e,00,78,00,36,\
  00,34,00,5c,00,62,00,69,00,6e,00,5c,00,6d,00,79,00,73,00,71,00,6c,00,64,00,\
  2e,00,65,00,78,00,65,00,22,00,20,00,4d,00,79,00,53,00,51,00,4c,00,00,00
"DisplayName"="MySQL"
"WOW64"=dword:0000014c
"ObjectName"="LocalSystem"

切换bat

echo off
echo 1 mysql5.1 
echo 2 mysql8.0
set /p var=请选择:

goto e%var%
goto end
:e2
net stop mysql
%~dp0\mysql8.0\reg8.0.reg
net start mysql
goto end
:e1
net stop mysql
"%~dp0\mysqlBag\MySQL Server 5.1_reg.reg"
net start mysql
goto end
pause

注:代码段需要按电脑自身的安装环境进行部分修改

你可能感兴趣的:(小技巧,mysql,数据库,服务器)