::0.复制文件到本地磁盘
::md D:\MySql
::xcopy G:\FSMetrol_Soft_instal\MySql\*.* D:\MySql /s
::1.配置环境变量
setx -m MYSQL_HOME "D:\mysql-8.0.18"
setx -m Path "%Path%;%%MYSQL_HOME%%\bin;"
::2.创建配置文件
set mysql=D:\mysql-8.0.18
echo [mysql]>%mysql%\my.ini
echo default-character-set=utf8>>%mysql%\my.ini
echo [mysqld]>>%mysql%\my.ini
echo port=3306>>%mysql%\my.ini
echo basedir=%mysql:\=\\%>>%mysql%\my.ini
echo datadir=%mysql:\=\\%\\data>>%mysql%\my.ini
echo max_connections=200>>%mysql%\my.ini
echo character-set-server=utf8>>%mysql%\my.ini
echo default-storage-engine=INNODB>>%mysql%\my.ini
::注册MySQL服务
mysqld --initialize-insecure --user=mysql
::xcopy G:\FSMetrol_Soft_instal\MySql\mysql-5.7.18-win32\my.ini D:\MySql\mysql-
5.7.18-win32
mysqld -install MySQL
::4.启动MySQL服务
@echo off
net start mysql && goto :success || goto :fail
exit
:success
echo success
::5.导入sql文件初始化数据库,使用sql文件初始化密码
mysql -uroot --skip-password -P3306 < %mysql%\init.sql
pause>nul
exit
:fail
echo failed
pause>nul
exit
end