programing

exec("mysqdump")에서 2를 반환하지만 명령줄에서 명령이 작동합니다.

iphone6s 2023. 8. 25. 23:22
반응형

exec("mysqdump")에서 2를 반환하지만 명령줄에서 명령이 작동합니다.

mysqdump를 통해 MySQL을 백업하려고 하는데 명령줄에서 명령이 작동하지만 exec()에서 2를 반환합니다.

제가 사용하는 코드는 다음과 같습니다.

$filename = "/path/to/backup/dbBackUp".date("Y-m-d").".sql";
$backupcmd = "/usr/bin/mysqldump -u USERNAME -pPASSWORD -A --single-transaction >".$filename;
exec($backupcmd, $output, $return);

$output의 Vardump는 배열(0) { }이고 $return = 2입니다.

알고 보니 www-data에 백업을 저장하는 폴더에 대한 쓰기 액세스 권한이 없었습니다.도와주셔서 고마워요.

언급URL : https://stackoverflow.com/questions/58561936/execmysqldump-returning-2-but-the-command-works-in-command-line

반응형