方法一:
生成general的表
Setting MySQL General Log
This topic describes setting MySQL general log table.
Add parameters to my.cnf file (For Windows, my.ini).
Go to %MYSQL_HOME directory.
Open my.cnf (for UNIX) or my.ini (for Windows) with your text editor.
Add the following parameters in [mysqld] section.
general_log=1
log_output=TABLE
Restart MySQL databases.Change the definition of "mysql.general_log" table.
Switch the engine from CSV to MyISAM. To switch the engine from CSV to MyISAM, execute the following commands (the default is ENGINE=CSV).
mysql> SET GLOBAL general_log = 'OFF';
mysql> ALTER TABLE mysql.general_log ENGINE = MyISAM;
mysql> SET GLOBAL general_log = 'ON';
Check the definition of "mysql.general_log" table. Execute the following SQL command:
mysql> show create table mysql.general_log\G;
-----------------------------------------+
| Table | Create Table
-----------------------------------------+
| general_log | CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TI
MESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
`server_id` int(11) NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='General log' |
+-------------+--------------------------------------------
Check if logging started. Execute the following command:
mysql> select * from mysql.general_log;
第二种方法:
mysql>set global general_log_file='/tmp/general.log';
mysql>set global general_log=on;
mysql>set global general_log=off;
查看tmp/general.log的信息,可以大致看到哪些sql查询/更新/删除/插入比较频繁了
第三种方法:
添加到my.cnf中(重启mysql生效)
general_log=1
general_log_file=’/tmp/general.log’;