<?PHP
$cmd = "mysqldump -u root db_name table_name > /var/path/filename.sql";
echo shell_exec($cmd);
?>
dump Mysql tables in centos server by using php code ...?
题
I am running one application in centos server.
I am trying to make dumping(BackUp) one table to folder
1st Example :
<?php
$cmd = "passwd";
echo exec($cmd,$arr);
print_r($arr);
?>
Output is :
Changing password for apache.
Array
(
[0] => Changing password for user apache.
[1] => Changing password for apache.
)
But While using mysqldump command i am getting empty array as a result
<?php
$cmd = "mysqldump -u root db_name table_name > /var/path/file.csv";
echo exec($cmd,$arr);
print_r($arr);
?>
Output:
Array()
Thanks
解决方案
其他提示
Might be password issue. Please try following code:
<?PHP
$cmd = "mysqldump --u root --p password db_name table_name > /var/path/filename.sql";
echo shell_exec($cmd);
?>
不隶属于 StackOverflow