4

I am working on java desktop application in which i use MYSQL database, but i have a problem , i want to embed MYSQL database, for this i want a script to install the MYSQL, i need Help to install MYSQL from batch file (windows).

i am using this script

@echo off
echo Installing MySQL Server. Please wait...

msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn

echo Configurating MySQL Server...

"%ProgramFiles%\MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe" 
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER 
DatabaseType=MYISAM Port=3306 Charset=utf8

echo Installation was successfully

i get the error,"The system cannot find the path specified".

Any help will be appreciated.

saurabh
  • 209
  • 1
  • 4
  • 17
  • 1
    Are you running the batchfile from the folder where mysql installer file is? – Mad Dog Tannen Nov 21 '13 at 10:57
  • yes the batch file is in same folder. – saurabh Nov 21 '13 at 11:25
  • Then %ProgramFiles% probably points to wrong directory. On my server, the Mysql folder for the server 5.6 is located in C:\Program Files\ , then MySQL also has a folder C:\Program Files x86\ - Here workbench and other odbc connectors are stored. Can you confirm that the %ProgramFiles% variables point to the correct folder? – Mad Dog Tannen Nov 21 '13 at 11:32

2 Answers2

2

I suspect that %ProgramFiles% is pointing to the wrong folder.

Try @echo %ProgramFiles% from a file to see what folder it is looking in. You have to make sure that it is not in the Program Files x86 folder.

I found this link also, maybe it can help you out?

Source: how to get program files x86 env variable?

EDIT

To be just sure, can you try it with the full path instead of the system variable?

Like this,

@echo off
echo Installing MySQL Server. Please wait...

msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn

echo Configurating MySQL Server...

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe" 
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER 
DatabaseType=MYISAM Port=3306 Charset=utf8

echo Installation was successfully

or even

@echo off
echo Installing MySQL Server. Please wait...

msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn

echo Configurating MySQL Server...
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin\" <-- set folder first, then run executeable
mysqlinstanceconfig.exe
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER 
DatabaseType=MYISAM Port=3306 Charset=utf8

echo Installation was successfully
Community
  • 1
  • 1
Mad Dog Tannen
  • 7,129
  • 5
  • 31
  • 55
  • Thanks for the reply . I am working on 32-bit windows, there is only one Program Files folder. – saurabh Nov 22 '13 at 05:07
  • 1
    I have managed to resolve the problem, the problem is that the msi file i was using did not create "MySQL\MySQL Server 5.6" folder in Program Files,so that system can not find the path specified.I was using the wrong .msi file ,now i am using "mysql-5.1.68-win32.msi" I have changed this command "msiexec /i "mysql-5.1.68-win32" /qn" to "msiexec /i "mysql-5.1.68-win32" /qb" ,it will install the mysql into Program Files and the system now did find the path to "\MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe" and sets the mysql configuration. – saurabh Nov 22 '13 at 09:55
2

My batch file complete:

@echo off
cls
echo ==========================================
echo MySQL Server - Installation - v.17/03/2014
echo ==========================================
echo .
echo .
rem ------------------------------------------------
echo Installing. Wait ...
msiexec /i "mysql-5.5.28-win32.msi" /qn
echo Done.
rem ------------------------------------------------
echo .
echo .
rem ------------------------------------------------
echo Configurating. Waiting ...
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
mysqlinstanceconfig.exe -i -q ServiceName=MySQL RootPassword=mypassword ServerType=DEVELOPER DatabaseType=INODB Port=myport Charset=utf8
echo Done.
rem ------------------------------------------------
echo .
echo .
rem ------------------------------------------------
echo Creating access to user. Waiting ...
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
mysql -uroot -pmypassword --execute="GRANT ALL PRIVILEGES ON . TO 'root'@'%%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;"
mysql -uroot -pmypassword --execute="FLUSH PRIVILEGES;"
echo Done.
rem ------------------------------------------------
echo .
echo .
echo Installation ready.
echo .
echo .
pause

Giovanni
  • 21
  • 1