MySQL client methods for exporting data tables

Source: Internet
Author: User
Tags mysql client php tutorial

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

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.