方法一:mysql
生成general的表sql
Setting MySQL General Logide
This topic describes setting MySQL general log table.spa
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.server
general_log=1xml
log_output=TABLEit
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).io
mysql> SET GLOBAL general_log = 'OFF';event
mysql> ALTER TABLE mysql.general_log ENGINE = MyISAM;table
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’;