mysqldump的where条件的妙用

来源:互联网 发布:c语言游戏源代码 编辑:程序博客网 时间:2024/06/02 17:39

有时候需要从mysql数据库用mysqldump一些条数的数据记录出来,用来在测试库做一些测试之类的工作,但是mysqldump本身并没有limit字句上的支持。

mysqldump这个命令是支持--where选项的,对于这个选项,官网给出的解释是:

 --where='where_condition'-w 'where_condition'

Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.

以前尝试过程直接将limit字句作为 --where选项的值,但是发现通不过编译,以为不知道这么做,其实是对--where选项是如何应用到mysqldump的数据查询上没有理解,今天尝试--where ' 1=1 limit 10',竟然通过了,而且给出的数据就是limit后的而结果,至少从此处看来,mysqldump是毫不犹豫的把--where选项的值直接字符串拼接到select语句后面了,恩,这就是说mysqldump是可以进行注入的,有趣。

原创粉丝点击