简体   繁体   中英

mysqldump.exe in php

i tried the solution of Ngu Soon Hui and it works. how about the mysqldump. i tried using the same solution.

$cmd = $mySQLDir1.' -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';
exec('"'.$cmd.'"',$out ,$retval);

where

$mysqlDire1 = $mySQLDir1='"C:\\Web\\WebServer\\mysql\\bin\\mysqldump.exe"';
$file2 = '"C:\\database_backup\\purchase_sales.sql"';

but this makes a file with this content.

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

any help will be appreciated.

You're not specifying which database to back up. Try adding it one, as the prompt suggests:

$cmd = $mySQLDir1.' mydatabasename -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';

Tested and works.

声明$cmd回显它后,首先要获取该输出,并将其键入到运行提示符或命令提示符下,然后查看输出是什么。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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