Method One
PHP tutorial with mysql command and shell
SELECT * into outfile './bestlovesky.xls ' from Bestlovesky where 1 order by id DESC limit 0, 50;
Method two Bestlovesky.xls open in text mode, then save As, select ANSI encoding in encoding, save
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
Method Three
MySQL your_database-uroot-p-E "select * from Test.table2" >/home/test.xls
Use the SZ command to download the file to local, open if the Chinese garbled,
because Office defaults to gb2312 encoding, the server-side generation is probably utf-8 encoded, and you have two options at this time, 1. Use Iconv on the server side for encoding conversion
Iconv-futf8-tgb2312-otest2.xls Test.xls
If the conversion goes well, it can be downloaded from the server.
If the conversion is not successful, you will be prompted: Iconv:illegal input sequence at position 1841 similar to this error,
First download the Test.xls down, this time the file is Utf-8 encoded, opened with Excel, garbled.
Open Test.xls as text, then save As, select ANSI encoding in encoding, save.
Method Four
Export Excel tables SQLyog and navicat directly using third-party software
This article is from the IT Network Tanuvi blog, be sure to keep this source http://03301216.blog.51cto.com/4550876/1861535
MySQL client methods for exporting data tables