mysql版本
mysql-5.6.35-winx64
路径关系
@echo off
Setlocal enabledelayedexpansion
@REM vscode中自动开启延迟环境变量扩展,
echo ********************************************************************
echo ** 安装mysql **
echo ********************************************************************
cd %~dp0
@REM 设置mysql安装路径
set mydqlInstallRoot=D:/DevelopmentTool
@REM mysql安装包名称
set mysqlPackage=mysql-5.6.35-winx64
echo 结束mysql服务
start /wait taskkill /f /im mysqld.exe
echo 1.解压复制mysql安装包
winrar x %mysqlPackage%.zip %mydqlInstallRoot% -o+
echo 2.生成mysql配置文件my.ini
D:
cd %mydqlInstallRoot%/%mysqlPackage%
echo [mysqld] > my.ini
echo basedir = %mydqlInstallRoot%/%mysqlPackage% >> my.ini
echo datadir = %mydqlInstallRoot%/%mysqlPackage%/data >> my.ini
echo sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES >> my.ini
echo 3.安装mysql服务
cd bin
mysqld install
echo 4.mysql服务设置为手动启动
sc config mysql start= demand
echo 5.启动mysql服务
net start mysql
echo 4.配置mysql环境变量
echo 提取系统级变量path
set key="HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/Environment"
for /F "skip=2 delims=" %%i IN ('reg query %key% /v "Path"') do (
echo 原始Path ======= %%i
set temppath=%%i
set temppath=!temppath:~29!
)
echo %temppath%
echo 设置mysql环境变量
setx /M mysql "%mydqlInstallRoot%/%mysqlPackage%"
setx /M path "%temppath%;%%mysql%%/bin"
echo ===========winrar环境变量设置完成,环境变量生效需重新打开cmd=========
pause
原创文章,作者:dweifng,如若转载,请注明出处:https://blog.ytso.com/267397.html