<?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 ...?
Question
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
Solution
OTHER TIPS
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);
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow