madams
27th July 2007 14:40 UTC
Confirm MySql Database Password
Hi,
Part of the installation for my program requires that a MySql database be created. To do this, I ask the user for their root mysql password, and then use this to execute an SQL file to build the database.
I was just wondering if there is anyway to validate the password before allowing the user to continue with the installation. If this is possible, please let me know.
Thanks!
Afrow UK
27th July 2007 15:29 UTC
How is the user entering it? Is it an InstallOptions dialog?
What kind of validation are you after?
Stu
madams
27th July 2007 15:41 UTC
Yea, the user enters the password via Install Options dialog. I was wondering if there was a way to check the password by attempting to execute some test command in MySql and seeing if it worked. I have no idea what command I would use or how I would see if it worked though.
Afrow UK
27th July 2007 16:20 UTC
Well if the SQL file execution fails then you should get an error code other than 0:
ExecWait command $R0
--or--
nsExec::Exec command
Pop $R0
Either will put the error code in $R0.
Stu
madams
27th July 2007 16:57 UTC
Thanks, I'll give that a shot.
madams
10th August 2007 14:57 UTC
Ok, this is the code I am using:
nsExec::Exec 'cmd /C IF 1==1 "$mysqlexebin\mysql.exe" -uroot -popen123'
Pop $R0
${if} $R0 != 0
MessageBox MB_OK "Error: Invalid MySql Root Password. Please try again."
Abort
${endif}
This code, however, doesn't work and will not abort or display the error message when I type in a wrong password. Does anybody know what I could be doing wrong?
Thanks!
madams
10th August 2007 16:35 UTC
Never mind, I just got it to work.