mysql dump使用php脚本 [英] mysql dump using php script
问题描述
我尝试下面的代码备份我的数据库db_school。
I tried the below code to backup my database "db_school".
<?php
shell_exec('mysqldump -u root -h localhost db_school > backup-file.sql');
?>
创建了名为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
-------------------------------------
注意:我的'root'用户没有密码
我知道有很多关于这个主题的帖子,类似上述
Note: my 'root' user has no password I know there are many posts on this topic but each suggests the code similar to above
推荐答案
确保具有完全权限的文件夹(777读/写)。
Make sure folder having full permission (777 read/write).
因为此代码会创建新文件名backup-file.sql,因此文件夹具有创建新文件的权限。
because this code create new file name "backup-file.sql" , so folder having permission to create new file.
请授予权限这个php文件执行的文件夹。
please give the permission to that folder where this php file executes.
这篇关于mysql dump使用php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!