2018-06-02 11:59:14

some trick about mysql's variable

query variable

show [global] variables; 
select @@<global variable>;
show [global] variables like '<variable>'

set variable

set [global] <variable>=<value>

take generating execution log on the fly for a example, when we want to check the execution log. First we should check the variable value:

mysql> show global variables like '%general_log%';
| Variable_name    | Value                                      |
| general_log      | OFF                                         |
| general_log_file | /usr/local/mysql/data/hoodeMacBook-Pro.log |

general_log manifest whether the current mysql program is generating the log or not and general_log_file is the location of the log (the result on your screen may be different)

and then, we should set the variable, so we can see the log

set global variable general_log=1;

and now you can use the following command to see the information of mysql's execution if there has none error happened.

sudo tail -f  /usr/local/mysql/data/hoodeMacBook-Pro.log

Permanent link of this article:http://nulls.cc/post/trick_about_variable_of_mysql

-- EOF --