直接在-e 里面执行你要的sql语句最后的参数是数据库名 mysql -uroot -pXXX -e "select host from hostinfo where tagged=1" db_hostlabel >./host.txt