Explain the tee function of MySQL and use it to record related operations

Source: Internet
Author: User
Tags mysql commands
Because a large number of changes are often performed on mysql databases, such as modifying fields, adding or deleting indexes, we put these operations into SQL statements, and then log on to mysql to access

Because a large number of changes are often performed on mysql databases, such as modifying fields, adding or deleting indexes, we put these operations into SQL statements, and then log on to mysql to access

Because we often perform a lot of changes to the mysql database, such as modifying fields, adding or deleting indexes, we put these operations into SQL statements, and then log on to mysql ,, execute this SQL file using source. In order to keep relevant records, check and query the SQL running results in MySQL in future work, and save them to the file, similar to using the spool function in Oracle sqlplus, the method is roughly as follows for reference only:

1. After logging on to mysql
Mysql> \ T mysql_result.log
Logging to file 'mysql _ result. Log'
Or
Mysql> tee mysql_result.log
Logging to file 'mysql _ result. Log'

2. [root @ ~] # Mysql -- tee = mysql_result.log

3. Close mysql, modify the [client] Option section in the mysql configuration file, and add the following content (tee =/tmp/mysql_result.log)
For example:
[Root @ ~] # Vim/usr/local/mysql/etc/my. cnf
[Client]
Tee =/tmp/mysql_result.log

The following are detailed records of my operations:
[Root @ ~] # Mysql-V
Mysql Ver 14.14 Distrib 5.1.45, for pc-linux-gnu (i686) using readline 5.1
[Root @ ~] # Mysql -- help | grep tee
-- Tee = name Append everything into outfile. See interactive help (\ h)
-- Disable-tee. This option is disabled by default.
-- No-tee Disable outfile. See interactive help (\ h) also. WARNING:
Option deprecated; use -- disable-tee instead.
[Root @ ~] # Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 5
Server version: 5.1.45 Source distribution

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql> \ h

For information about MySQL products and services, visit:

For developer information, including the MySQL Reference Manual, visit:

To buy MySQL Enterprise support, training, or other products, visit:
Https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end ';'
? (\?) Synonym for 'help '.
Clear (\ c) Clear the current input statement.
Connect (\ r) Reconnect to the server. Optional arguments are db and host.
Delimiter (\ d) Set statement delimiter.
Edit (\ e) Edit command with $ EDITOR.
Ego (\ G) Send command to mysql server, display result vertically.
Exit (\ q) Exit mysql. Same as quit.
Go (\ g) Send command to mysql server.
Help (\ h) Display this help.
Nopager (\ n) Disable pager, print to stdout.
Notee (\ t) Don't write into outfile.
Pager (\ P) Set PAGER [to_pager]. Print the query results via PAGER.
Print (\ p) Print current command.
Prompt (\ R) Change your mysql prompt.
Quit (\ q) Quit mysql.
Rehash (#) Rebuild completion hash.
Source (\.) Execute an SQL script file. Takes a file name as an argument.
Status (\ s) Get status information from the server.
System (\!) Execute a system shell command.
Tee (\ T) Set outfile [to_outfile]. Append everything into given outfile.
Use (\ u) Use another database. Takes database name as argument.
Charset (\ C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
Warnings (\ W) Show warnings after every statement.
Nowarning (\ w) Don't show warnings after every statement.

For server side help, type 'help CONTENTS'

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.