Save the SQL run results in MySQL to a file

Source: Internet
Author: User
Tags mysql command line

Method One: Use the tee in the mysql> prompt


Mysql> Tee output.txt

Logging to file ' Output.txt '

Mysql> notee

Outfile disabled.

Or

mysql> \ Output.txt

Logging to file ' Output.txt '

mysql> \ t

Outfile disabled.


This spool function, similar to Sqlplus, allows you to save the results from the command line to an external file. If you specify a file that already exists, the result is appended to the file.


Method Two: Use the--tee parameter of the MySQL command line tool


$mysql--tee=ot.txt


Logging to file ' Ot.txt '


Mysql>


This will log all input and output contents to the specified file (until exit). If you specify a file that already exists, the result is appended to the file.


This article is from the "Programming Art" blog, so be sure to keep this source http://itsart.blog.51cto.com/1005243/1871169

Save the SQL run results in MySQL to a file

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.