Mysql imports data to excel, mysqlexcel

Source: Internet
Author: User

Mysql imports data to excel, mysqlexcel

Create a test data table first

Create table users (

Username varchar (40) not null,

Password varchar (40) not null) charset = utf8;

Insert data

Insertinto users values ("admin", "admin ");

Insertinto users values ("Liyang silence", "Wang Peikun ");

Use the following sentence to write data in the database to the test.xls file.

Mysql> select username, password from users into outfile "d: \ test.xls ";

(Note: mysql must have the write permission on the file path)

(Alternatively, use the following statement to export the data to excel: select * into outfile "d: \ test1.xls" from test ;)

Because the default office Code is gb2312, and the server may use UTF-8, the excel file may contain garbled characters, as shown below:


We can recode a field as follows:

Mysql> select convert (username using gb2312), convert (password using gb2312) from

Users into outfile "d: \ test.xls ";

This is the normal display in the file:


Mysql> select convert (username using gb2312), convert (password using gb2312) from

Users into outfile "d: \ test.xls ";

Related Article

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.