dump matching tables php

扶醉桌前 提交于 2019-12-11 09:25:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!