简体   繁体   中英

How to create Batch file to execute sql script

I'm in the last step to create an installation of a java swing application with inno setup. In this installation I call a batch file that get the installation of mysql . My problem is that I want to call a sql script from a batch file, that's what I do but it's doesn't work:

@echo off
C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql -u root -p password < dbase.sql;

( * 'dbase.sql ' in this script a create the database with tables). *

and here I execute that batch file in inno setup:

[Run]

Filename: "C:\Documents and Settings\esolutions\Mes documents\dumps\install.bat"; Flags: shellexec waituntilterminated

So when I install the program. I run mysql command line and I find that the script is not executed (no database created)

You have to omit the space after -p too.

@echo off
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" -u root -ppassword < dbase.sql;

Change your script as below

@echo off
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" -u root -p password < dbase.sql;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM