I'm trying to import mysql databases from a file in a groovy script.
I'm trying like this:
command = """mysql -f -u ${settings.dbUser} -p${settings.dbPassword} -h localhost --default-character-set=latin1 ${settings.dbName} < "$tableDefinitions" """
commandArray[0] = "cmd"
commandArray[1] = "/c"
commandArray[2] = "start " + command
def Process process = new ProcessBuilder(commandArray)
.directory(workingDir)
.redirectErrorStream(true)
.start()
If I output the command on the console it looks like this:
mysql -f -u root -pHelloStackOverflow -h localhost --default-character-set=latin1 test123 < "C:\Users\XXX\git\YYY\commons\sqlData\table.sql"
However if I do this all that happens is a mysql console window opens, and I'm already logged into it, but nothing was imported. If I execute the same command on the console it works.
I tried calling mysql directly instead of cmd, but then I get the error "cannot run command", "system can't find the specified file"
How can I import like that without the mysql console opening?