# 查询表tablename 输出内容到/tmp/tablename.csv # 字段制表符为,分割:fields terminated by: # 字段包裹:optionally enclosed by # 换行: lines terminated by select * from tablename into oufile '/tmp/tablename.csv' fields terminated by ',' optionally enclosed by ' " ' lines terminated by '\n'
# 步骤1: 执行sql 输出到文本,sql根据自己需求编写 mysql -uusername -p -e "select * tablename" > filename.csv # 步骤2: 修改制表符为逗号 sed -i 's/\t/,/g' filename.csv
mysql 加 --html 参数
# 步骤1: 执行sql 输出到文本,sql根据自己需求编写 mysql -uusername -p --html -e "select * tablename" > filename.html
mysql 加 --xml 参数
# 步骤1: 执行sql 输出到文本,sql根据自己需求编写 mysql -uusername -p --xml -e "select * tablename" > filename.html