I have an extremely simple script with PHP exec, calling mysql command:
exec
mysql
$dbhost = \'localhost\'; $dbuser = \'root\'; $dbpass
I found the solution
The problem is that you need to explicitly enclosed the $cmd in "".i.e.,
$cmd
exec('"'.$cmd.'"',$out ,$retval);
This is the full code that works: