MySQL56打印sql执行语句

1.临时方法:

查看设置:

 ([email protected]) [(none)]> show global variables like '%log%';

+-----------------------------------------+----------------------------------------+

| Variable_name                          | Value                                  |

+-----------------------------------------+----------------------------------------+

| back_log                                | 80                                    |

| expire_logs_days                        | 14                                    |

| general_log                            | ON                                    |

| general_log_file                        | /opt/mysql/log/mysql-general.log      |

| log_bin                                | ON                                    |

| log_bin_basename                        | /opt/mysql/log/bin-log/mysql-bin      |

| log_bin_index                          | /opt/mysql/log/bin-log/mysql-bin.index |

| log_bin_trust_function_creators        | OFF                                    |

| log_bin_use_v1_row_events              | OFF                                    |

| log_error                              | /opt/mysql/log/mysql-error.log        |

| log_output                              | FILE                                  |

| log_queries_not_using_indexes          | OFF                                    |

| log_slave_updates                      | OFF                                    |

| log_slow_admin_statements              | OFF                                    |

| log_slow_slave_statements              | OFF                                    |

| log_throttle_queries_not_using_indexes  | 0                                      |

+-----------------------------------------+------------------------

如果不是请设置:

 ([email protected]) [(none)]>set global general_log=1;

 ([email protected]) [(none)]>set global log-output=FILE

 ([email protected]) [(none)]>set global general_log_file ='/opt/mysql/log/mysql-general.log '

注意:此方法重启会消失,需要重新配置

2.永久方法:

编辑配置文件,加入:

vi my.cnf

log-output=FILE

general-log=1

log="/opt/mysql/log/mysql-general.log "

重启mysql。

你可能感兴趣的:(MySQL56打印sql执行语句)