On my Ubuntu 18.04 command-line, this works perfectly:

```
mysqldump --user="myuser" --password="mypassword" --skip-lock-tables --single-transaction --no-tablespaces  mydb | gzip > /home/userhome/database_backup.sql.gz

```

So I create a PHP script having exact same (as a troubleshooting step):

```
exec("mysqldump --user=\"myuser\" --password=\"mypassword\" --skip-lock-tables --single-transaction --no-tablespaces  mydb | gzip > /home/userhome/database_backup.sql.gz", $output, $worked);

switch($worked){
    case 0:
        echo "database backed up successfully";
        break;
    case 1:
        echo "database back up failed";          
        break;
}

var_dump($output);

```

Script outputs:

```
database back up failed
array(0) { }

```

How do I resolve this especially with no useful error given in output?

Been through [this](https://stackoverflow.com/questions/3460636/shell-command-works-on-command-line-but-not-in-php-exec) and [this](https://stackoverflow.com/questions/22789849/exec-command-not-working-in-php-but-works-in-terminal-putty) but none of these apply. I have checked permissions and database access passwords and all seem ok.