MySQL Import Excel method

Source: Internet
Author: User

MySQL Tutorial Import Excel method

The simplest way is to use the PHP tutorial myadmin directly import xls file on it, this is not much said below to see about PHP with the command of MySQL and shell combination of two methods.


Method One:

SELECT * into outfile './zhutiai.xls ' from Zhutiai where 1 the ORDER by id DESC limit 0, 50;


Method Two:

echo "Select Id,name from Zhutiai where 1 order by id DESC limit 0, 50;" | /usr/local/mysql/bin/mysql-h127.0.0.1-uroot-p123456 >/data/zhutiai.xls


Because office defaults to gb2312 encoding, server-side generated is likely to be utf-8 encoding, may lead to the export of Chinese garbled, the solution is as follows:

Method 1. Using Iconv on the server side for encoding conversion

Iconv-futf8-tgb2312-ozhutiai2.xls Zhutiai.xls


Method 2. Open Zhutiai.xls as text, then save As, select ANSI encoding in encoding, save

If Method 1 conversion is not smooth, you will be prompted: Iconv:illegal input sequence at position 1841 is similar to this error.
First download the Zhutiai.xls down, this time the file is Utf-8 encoded, with Excel open, garbled.
Open Zhutiai.xls as text, then save As, select ANSI encoding in encoding, save

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.