I want to run mysqldump
from PHP by using proc_open()
. The problem is that PHP script is called from shell and I still get Enter password:
prompt.
$cmd = "mysqldump -u ".$db_user." -p -h ".$db_host." ".$db_name." > /files/database-backups/db-backup.sql";
$desc = [
0 => ["pipe", "r"]
];
$p = proc_open($cmd, $desc, $pipes);
fwrite($pipes[0], $db_pass);
fclose($pipes[0]);
proc_close($p);
I want it to get the password and finish without the need for any external input. Is it possible? If yes how to make it work using the code above?
Answers from the other question do not apply to this one: I can't use password inside the command, I can't use external config file, I don't want to use export
command.