简体   繁体   中英

syntax to exclude a table with mysqldump

Going nuts. I don't find this exact line and using the example at the reference from MySQL, I'm obviously crossed-eyed here!

This is the wrong syntax but I'm not sure where to put the option --ignore-table=search_index and have tried many variations except the right one!

$cmd = "mysqldump -u --ignore-table=search_index " . $prod_db_user . " -p" . $prod_db_pass . " " . $prod_db_1 . " > " . $qa_backup_name;

I'm just trying to dump the database and exclude a table that is named search_index.

Thanks

Place the $prod_db_user username after -u , as that is the username flag.

$cmd = "mysqldump -u{$prod_db_user} --ignore-table=search_index  -p{$prod_db_pass} $prod_db_1  > $qa_backup_name";

Since this is a double-quoted string, all the PHP variables can go directly into the string. However, be sure to escape them with escapeshellarg() first!.

$prod_db_user = escapeshellarg($prod_db_user);
$prod_db_pass = escapeshellarg($prod_db_pass);
// etc...

Finally, depending on the execution environment, it may be necessary to specify the full path to mysqldump (if it isn't otherwise found in the $PATH (or %PATH% ) environment variable.

$cmd = "/path/to/mysqldump -u{$prod_db_user} ....";

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