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 @ www.bkjia.com ~] # 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 @ www.bkjia.com ~] # Vim/usr/local/mysql/etc/my. cnf
[Client]
Tee =/tmp/mysql_result.log
The following are detailed records of my operations:
[Root @ www.bkjia.com ~] # Mysql-V
Mysql Ver 14.14 Distrib 5.1.45, for pc-linux-gnu (i686) using readline 5.1
[Root @ www.bkjia.com ~] # 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 @ www.bkjia.com ~] # 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:
Http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
Http://dev.mysql.com/
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'