-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmysql_start.bat
More file actions
78 lines (61 loc) · 1.96 KB
/
mysql_start.bat
File metadata and controls
78 lines (61 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
:########################################################################
:# File name: mysql_start.bat
:# Created By: rAthena Development Team
:# Edited Last By: Gepard
:# V 1.1 20.01.2012
:########################################################################
@echo off
rem ## Save return path
pushd %~dp0
rem ## Check to see if already stopped
if NOT exist udrive\data\%COMPUTERNAME%.pid goto :NOTSTARTED
rem ## It exists is it running
SET /P pid=<udrive\data\%COMPUTERNAME%.pid
netstat -anop tcp | FIND /I " %pid%" >NUL
IF ERRORLEVEL 1 goto :NOTRUNNING
IF ERRORLEVEL 0 goto :RUNNING
:NOTRUNNING
rem ## Not shutdown using mysql_stop.bat hence delete file
del udrive\data\%COMPUTERNAME%.pid
:NOTSTARTED
rem ## Check for another server on this MySQL port
netstat -anp tcp | FIND /I "0.0.0.0:3306" >NUL
IF ERRORLEVEL 1 goto NOTFOUND
echo.
echo Another server is running on port 3306 cannot run MySQL server
echo.
goto END
:NOTFOUND
echo Port 3306 is free - OK to run server
rem ## Find first free drive letter
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do CD %%a: 1>> nul 2>&1 & if errorlevel 1 set freedrive=%%a
rem ## Use batch file drive parameter if included else use freedrive
set Disk=%1
if "%Disk%"=="" set Disk=%freedrive%
rem ## To force a drive letter, remove "rem" and change drive letter
rem set Disk=w
rem ## Having decided which drive letter to use create the disk
subst %Disk%: "udrive"
rem ## Save drive letter to file. Used by mysql_stop.bat
(set /p dummy=%Disk%) >udrive\data\drive.txt <nul
rem ## Start server
%Disk%:
:start \bin\mysqld-opt.exe --defaults-file=/bin/my-small.cnf
start \bin\mysqld.exe --no-defaults
rem ## Start HeidiSQL. Rem next line to disable
start \bin\heidisql.exe
rem ## Info to user
CLS
echo.
echo The MySQL server is working on disk %Disk%:\ [port 3306]
goto :END
:RUNNING
CLS
echo.
echo This MySQL server already running.
echo You can stop the server using mysql_stop.bat
:END
echo.
pause
rem ## Return to caller
popd