1、如果MYSQL服务器就是你要导出文件的机器,那么可以直接用
select ...into outfile
select * from rank into outfile "/home/a.txt"
mysql -uroot -proot -P3310 -h10.1.2.3 dbname -e "select * from rank" > /home/a.txt
mysql>tee /home/a.txt mysql>select * from rank; mysql>exit
mysql -uroot -p dbname -e "select * from user_role_new ; show profile cpu , block io for query 15" > ~/aa.txt