我怎么知道我的mysqldump失败的原因? 请参阅邮件错误

I have a little PHP script to backup a database to a file. It has been working for years but something changed in the server and now it doesn't work.

The var $worked is "2" and "$output" is empty (I tried to echo it). The username, passw etc are correct in the original script.

How can I see some message error?

$mysqlDatabaseName ='databaseName';
$mysqlUserName ='userName';
$mysqlPassword ='passw';
$mysqlHostName ='hostName';
$mysqlExportPath ='folder/name.sql';


$command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' > ~/' .$mysqlExportPath;
exec($command,$output=array(),$worked);
switch($worked){
case 0:
    echo 'Database <b>' .$mysqlDatabaseName .'</b> successfully exported to <b>~/' .$mysqlExportPath .'</b>';
    break;
case 1:
    echo 'There was a warning during the export of <b>' .$mysqlDatabaseName .'</b> to <b>~/' .$mysqlExportPath .'</b>';
    break;
case 2:
    echo 'There was an error during export.';
    break;

}

Thanks.