简体   繁体   English

备份.sql文件为空

[英]backup .sql file is empty

i am trying to backup mysql database by using this code 我试图使用此代码备份mysql数据库

    include ("functions_cp/f_connection.php");

        Sqlconnection() ;



    $dbname = "Reservebox";
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "123";



$backupFile =  $dbname . date("Y-m-d-H-i-s") . '.sql';

$command = 'mysqldump -h' .  $dbhost . ' -u ' . $dbuser . '-p =' . $dbpass . ' '. $dbname . ' > ' . $backupFile ;
system($command);

the script works fine and it generates a .sql file , however this file is empty , how can i fix this problem ? 该脚本工作正常,它生成一个.sql文件,但是这个文件是空的,我该如何解决这个问题?

thanks 谢谢

Don't put a space or equals sign between the -p and the password. 不要在-p和密码之间放置空格或等号。 Also, you are missing a space before the -p . 此外,您在-p之前缺少空格。

$command = 'mysqldump -h' .  $dbhost . ' -u ' . $dbuser . ' -p' . $dbpass . ' '. $dbname . ' > ' . $backupFile ;

Probably a file permissions error. 可能是文件权限错误。 Check that whatever user PHP and MySQL are running as have the permissions to write the file. 检查PHP和MySQL运行的用户是否具有写入文件的权限。 FOr troubleshooting purposes, chmod the directory to 0777 and see if that fixes the problem. 为了解决问题的目的,请将目录chmod到0777并查看是否可以解决问题。 If so, chown the directory to whatever user MySQL is running as. 如果是这样,将目录chown到MySQL运行的任何用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM