问题
I'm trying to dump some of my tables if the prefix of theme is matching a given sub string using php. Trying to use php's system
did not bring any result in sense the dump file was not created. I thought to use the command line function exec
to achieve my result and I was making the following
exec('E:/xampp/mysql/bin/mysqldump '. $dbname .' -h '. $this->host .' -u ' .$this->user . ' $(E:/xampp/mysql/bin/mysql -u '. $this->user . ' -p ' . $dbname .' -Bse "show tables like \'wp_dev%\'")> mydb.sql 2>&1', $output);
but to sub query what would filter out the matching tables is returning the following error
mysqldump: unknown option '-s'
It seems like I'm missing something by the syntax.
回答1:
Use like this, it will take dump of only listed tables.
exec('E:/xampp/mysql/bin/mysqldump -h '. $this->host .' -u ' .$this->user . ' -p'. $this->password .' '. $dbname .' table1 table2 > /path_to_file/dump_file.sql');
来源:https://stackoverflow.com/questions/13668766/dump-matching-tables-php