mysql -X -uroot -proot -e "use test; show variables like '%version%';"


参数-X表示生成xml格式的输出 , 参数-e表示执行后面的命令 


导出表数据到xml文件

mysql -X -uroot -proot -e "use test; select * from test;" > ./a.xml 



导入xml文件的内容到数据库表,这里主要用到了load_file()函数

 



mysql -uroot -h127.0.0.1 -e "use 库名 ; delete from 库名;" 


mysql -uroot -h127.0.0.1 -e "use 库名 ; insert into 数据库1 select * from 数据库2 where status = 10;"