Reputation: 465
I tried the below code to backup my database "db_school".
<?php
shell_exec('mysqldump -u root -h localhost db_school > backup-file.sql');
?>
The new file named "backup-file.sql" is created but, the problem is that it is totally empty. Following is my database table:
-------------------------------------
id | school_name | city
-------------------------------------
1 | cp school | New York
2 | public school | San Fracisco
-------------------------------------
Note: my 'root' user has no password I know there are many posts on this topic but each suggests the code similar to above
Upvotes: 0
Views: 323
Reputation: 1124
Make sure folder having full permission (777 read/write).
because this code create new file name "backup-file.sql" , so folder having permission to create new file.
please give the permission to that folder where this php file executes.
Upvotes: 1
Reputation: 4506
try this dear
a set of one or more complete databases
<?php
shell_exec('mysqldump -u root -h localhost --database db_school > backup-file.sql');
?>
Upvotes: 0