Reputation: 741
I am trying to make a custom installer that silently installs MySQL but I am encountering the same problem for days. After installing the MySQL server, the initialization fails thus, when I try to type the password it closes instantly(meaning that the password was either wrongly set or even worse, wasn`t set at all).
Here is the code for the installer:
!define PRODUCT_NAME "Soft1" !define PRODUCT_VERSION "1.0" !define PRODUCT_PUBLISHER "Zaco"SetCompressor lzma
!include "MUI2.nsh"
!define MUI_ABORTWARNINGS !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_WELCOMEPAGE_TEXT "Welcome txt"
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Lic.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "Soft1.exe" InstallDir "$PROGRAMFILES\Soft1" ShowInstDetails show
Section -Settings SetOutPath "$INSTDIR" SetOverwrite ifnewer SectionEnd
Section "MySQL" SEC_01
File mysql.msi ExecWait 'msiexec /i "$INSTDIR\mysql.msi" /quiet' SetOutPath "$PROGRAMFILES\MySQL\MySQL Server 5.1" File my.ini File mysql-init.txt ExecWait '"$PROGRAMFILES\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file = "$PROGRAMFILES\MySQL\MySQL Server 5.1\my.ini" ' ExecWait '"$PROGRAMFILES\MySQL\MySQL Server 5.1\bin\mysqld" --init-file = "$PROGRAMFILES\MySQL\MySQL Server 5.1\mysql-init.txt" ' ExecWait "Net Start MySQL"
SectionEnd
The content of the my.ini file is copied from the my.ini file created after manually installing and configuring MySQL Server using the MySQL Server Instance Configuration Wizard. The mysql-init.txt contains the following code:
CREATE USER root IDENTIFIED BY PASSWORD 'New_Password'; GRANT ALL PRIVILEGES ON * . * TO 'root'@ 'localhost' IDENTIFIED BY 'New_Password' WITH GRANT OPTION ;
I also tried using this code for the mysql-init.txt but I get the same result:
UPDATE mysql.user SET Password=PASSWORD(’New_Password’) WHERE User=’root’; FLUSH PRIVILEGES;
Furthermore, if try to configure the Server using the MySQL Server Instance Configuration Wizard, it let me choose those options as if the initialization commands from the installer had no effect at all on the Server.
Any suggestions on how I could solve this problem are welcome.
Thanks in advance for your concern!
Upvotes: 1
Views: 2755
Reputation: 3555
I find that when calling a command line app that requires parameters that contain quotes, it is best to call cmd.exe with the /S parameter and pass the command line itself as parameters. So using your example you would use this:
ExpandEnvStrings $ComSpec %COMSPEC%
ExecWait '"$ComSpec" /S /C ""$PROGRAMFILES\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file = "$PROGRAMFILES\MySQL\MySQL Server 5.1\my.ini""'
ExecWait '"$ComSpec" /S /C ""$PROGRAMFILES\MySQL\MySQL Server 5.1\bin\mysqld" --init-file = "$PROGRAMFILES\MySQL\MySQL Server 5.1\mysql-init.txt""'
Upvotes: 1