Shellrun using CMD to open mysql

Asked

Viewed 1,901 times

1

Gentlemen, I’d like to ask you if you can use the command cmd to run mysql.exe on it, let me use a line of code:

ShellExecute(Handle,'open',PChar('cmd.exe'),PWideChar('/k cd\mysql\bin & mysql.exe --host 192.168.0.50 --user root --database=sinval --password= Repair Table item'), nil, SW_SHOW);

I want that in the last parameter passage of Shellexecute(), it execute an sql command, being more clear, I would like it to be like this:

ShellExecute(Handle,'open',PChar('cmd.exe'),PWideChar('/k **Comando cmd & comando para entrar no mysql | comando sql**'), nil, SW_SHOW);

So, what do you think? Is there a better way to do this? If you don’t understand, please speak, I will try to see a better explanation.

1 answer

4


You need to pass the option -e or --execute followed by the command you want to execute. For example:

mysql.exe --host 192.168.0.50 --user root --database=sinval --password=bla --execute "SELECT * FROM tbl"
  • Boy, it worked perfectly, thank you!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.