Archive: MySQL


MySQL
I have searched this forum and the NSIS wiki and everything that I can think of for an answer to this problem.

What I need to do is connect to a mysql database and create tables based on a .sql or .bat file. What I have so far is just me trying to do something with the database, connecting, a select query, and then exiting.

This is the contents of the bat file:

mysql mysql
SELECT * FROM user
quit


This works perfectly in cmd.exe when I execute it out of NSIS. But when I attempt to execute it as a part of an NSIS installer it freezes the installer and I have to force quit.

This is the contents of the .nsi file which includes as many plugins or code that I could find that could possibly do this job.

Name "${APP_NAME} Test"
OutFile "${APP_NAME}.exe"

Section ""

;nsExec::ExecToLog '"mysql -u root --force SAM" < bat'
;nsExec::ExecToLog '"$0" /C "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe" -uroot < "C:\Documents and Settings\Hess Smith\schema.sql"'

ExecDos::exec "$EXEDIR\mysql.bat" "" "$EXEDIR\execdos.log"
POP $0
MessageBox MB_OK "Exit Code $0"

SectionEnd


Does anybody know of code that can accomplish what I need? Does anybody see any mistakes in my code that could be holding up the installer?

Thank you all who might be of help to me.

Hess Smith

I have figured out how to do this with two .bat files and Exec Shell:

Just for people who may be looking at this in the future.

connect.bat

pause
mysql SAM < "db function.bat"


db function.bat
USE your-DB

**SQL QUERY CODE GOES HERE**


Then in the installer, this is what I have:


Section ""

ExecShell "open" "$EXEDIR\connect.bat"

SectionENd

If you want to use > to redirect output to a file (or < to use input from a file) then you need to use the command line processor, as described in this thread:

http://forums.winamp.com/showthread....hlight=COMSPEC