mysql常用功能,把某个表的某个字段按要求按区间批量导出,mysql -uroot mysql -uroot -p,非常实用
1 2 3 4 5 6 7 8 9 10 11 |
mysql -uroot -p fozhu920 -e "SELECT ID,post_title from wp_posts where post_title like '%空空%' and id >= 1510407 and id <= 1527738 INTO OUTFILE'/www/wwwroot/temp/myid.txt'" mysql -uroot -p xpfengshui -e "SELECT ID,post_title from wp_posts where post_title like '%大大%' and id >= 1527739 and id <= 1632249 INTO OUTFILE'/www/wwwroot/temp/you2.txt'" mysql -uroot -p xpfengshui -e "SELECT ID,post_title from wp_posts INTO OUTFILE'/www/wwwroot/temp/liutitle.txt'" mysql -uroot -p xpfengshui -e "SELECT ID,post_title from wp_posts where id >= 1320531 and id <= 1454087 INTO OUTFILE'/www/wwwroot/temp/y1title.txt'" mysql -uroot -p xpfengshui -e "SELECT term_id,name,slug from wp_terms where term_id>= 1872 and term_id <= 1248738 INTO OUTFILE'/www/wwwroot/temp/term.txt'" mysql -uroot -p soso -e "SELECT source,title,litpic from dede_archives INTO OUTFILE'/www/wwwroot/temp/so.txt'" mysql -uroot -p fozhu001 -e "SELECT ID,post_title,post_content from wp_posts INTO OUTFILE'/www/wwwroot/temp/fozhu001.txt'" mysql -uroot -p xpfengshui -e "SELECT ID,post_content from wp_posts where length(post_content)>20000 INTO OUTFILE'/www/wwwroot/temp/aa.txt'" mysql -uroot -p xpfengshui -e "SELECT ID,post_title from wp_posts where length(post_title)>500 INTO OUTFILE'/www/wwwroot/temp/xp500.txt'" |
备注,如何出现:The MySQL server is running with the –secure-file-priv option so it cannot execute this statement
解决办法:在宝塔mysql配置里加上 secure_file_priv =
保存,重启mysql
注意,确保wwwroot/temp目录可写入,先设置好777,导出后再设置回644
延伸用法