Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2284665
  • 博文数量: 266
  • 博客积分: 5485
  • 博客等级: 大校
  • 技术积分: 3695
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-20 11:05
个人简介

多读书,多做事,广交朋友,趣味丛生

文章分类

全部博文(266)

分类: LINUX

2011-12-09 13:04:34

方法一

用mysql的命令和shell

select * into outfile './bestlovesky.xls' from bestlovesky where 1 order by id desc  limit 0, 50;


方法二 把bestlovesky.xls以文本方式打开,然后另存为,在编码选择ansi编码,保存

echo "select id,name from bestlovesky where 1 order by id desc limit 0, 50;"| /usr/local/mysql/bin/mysql -h127.0.0.1-uroot -p123456 > /data/bestlovesky.xls


方法三

mysql your_database  -uroot  -p  -e  "select   *   from   test.table2 "   >   /home/test.xls

用sz命令将文件下载到本地,打开如果中文乱码,

因为office默认的是gb2312编码,服务器端生成的很有可能是utf-8编码,这个时候你有两种选择,1.在服务器端使用iconv来进行编码转换
iconv -futf8 -tgb2312 -otest2.xls test.xls
如果转换顺利,那么从server上下载下来就可以使用了。
转换如果不顺利,则会提示:iconv: illegal input sequence at position 1841 类似于这样的错误,
先把test.xls下载下来,这个时候文件是utf-8编码的,用excel打开,乱码。
把test.xls以文本方式打开,然后另存为,在编码选择ANSI编码,保存。
阅读(37851) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~