方法一
php教程用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 DB_name -h10.36.10.11 -utest -p -e "select * from TABLE_name where acti_type <> '无效'; order by acti_date desc" > ./test.txt
-N 即可 -N, --skip-column-names.Don't write column names in results.
默认带有字段名/列名,不输出列名使用-N参数。
因为office默认的是gb2312编码,服务器端生成的很有可能是utf-8编码,这个时候你有两种选择,1.在服务器端使用iconv来进行编码转换
转换如果不顺利,则会提示:iconv: illegal input sequence at position 1841 类似于这样的错误,
先把test.xls下载下来,这个时候文件是utf-8编码的,用excel打开,乱码。
把test.xls以文本方式打开,然后另存为,在编码选择ANSI编码,保存。
load data infile '/home/mysql/all_0914.csv'
into table `DB_name`
character set utf8
fields terminated by '^'
lines terminated by '\n';