解压版 不做自启 用作备用数据库 端口3366 使用 :
echo 2. 进入mysql 2免密登录 在 mysql根目录放一个 my.ini 文件 👇
- 主要是设置一些初始配置
navicat 连接设置
echo 2. 进入mysql 2免密登录 alter user ‘root’@’localhost’ identified with mysql_native_password by ‘root’; flush privileges;
mysqlStartUp.bat
@echo off & setlocal:loopset /p mysqlPath=mysql路径(D:\mysql-8-winx64\):#set mysqlPath=C:\Users\WDAGUtilityAccount\Desktop\mysql\mysql-8.0.23-winx64\mysql-8.0.23-winx64set setMysql=mysqldset fileName=%setMysql%.exe:mysqlFunctionecho ================ 选择mysql功能 ===============echo.set currentDir=%mysqlPath%\binset drives=%mysqlPath:~0,2%set dataFolder=%mysqlPath%\dataecho %currentDir%echo %drives%echo %dataFolder%echo.echo -------------------------------------echo 1. 启动mysql 1echo 2. 进入mysql 2echo 3. 结束进程mysql 3echo ==========PRESS '0' TO QUIT==========echo.echo.set input=set /p input=Please select a number:if /i '%input%'=='1' goto startMysqlif /i '%input%'=='2' goto goMysqlif /i '%input%'=='3' goto killMysqlif /i '%input%'=='0' goto endecho.echo.rem 输入错误跳回 inputecho wrong number, try it again&&goto mysqlFunction:startMysqlecho.call taskkill /f /im %fileName%if %errorlevel% == 0 (echo 杀死%setMysql%进程成功) else (echo 杀死%setMysql%进程失败)echo.echo Starting %setMysql% ...if exist %dataFolder% (rem 目录data已存在,无需创建echo 目录%dataFolder%目录已存在,无需创建!goto startMysqlSucceed) else (rem 创建data目录,使用复制方法echo %dataFolder%目录不存在,已创建该目录!md %dataFolder%rem 睡3秒创建文件夹timeout /T 3 /NOBREAKrem 睡醒了cd /d %currentDir%call %setMysql% --initialize-insecure --console && (goto startMysqlSucceed) || goto startMysqlFailed):startMysqlSucceedrem 睡三秒timeout /T 3 /NOBREAKcd /d %currentDir%echo 当前路径 %cd%start %fileName%echo 启动%setMysql%成功echo.echo.goto loop:startMysqlFailedecho 初始化失败 删除文件夹rd /s /q %dataFolder%goto end:goMysqlecho.echo.cd /d %currentDir%echo 当前路径 %cd%mysqld --console --skip-grant-tables --shared-memorycall mysql -urootif %errorlevel% == 0 (echo 启动%setMysql%命令行成功) else (echo 启动%setMysql%命令行失败)echo.echo.goto loop:killMysqlecho.echo 当前路径 %cd%echo.call taskkill /f /im %fileName%if %errorlevel% == 0 (echo 杀死%setMysql%进程成功) else (echo 杀死%setMysql%进程失败)echo.echo.goto loopgoto end:no:endecho Good-bye!pause
my.ini
[mysql]#设置mysql客户端默认字符编码形式default-character-set=utf8mb4[mysqld]#设置端口号,默认3366port = 3366#设置最大连接数max_connections=200#允许连接失败的次数max_connect_errors=10#服务端使用的字符集默认为utf8mb4character-set-server=utf8mb4#创建新表时将使用的默认存储引擎default-storage-engine=INNODB#默认使用“mysql_native_password”插件认证#mysql_native_passworddefault_authentication_plugin=mysql_native_password[client]#设置mysql客户端连接服务端时默认使用的端口port=3366default-character-set=utf8mb4
