I have an extremely simple script with PHP exec, calling mysql command:
exec
mysql
$dbhost = \'localhost\'; $dbuser = \'root\'; $dbpass
there should be no space between -p and mypass.
-p
mypass
BTW I suggest you use the form --password=mypass
--password=mypass