mysql general log_设置mysql的general log

方法一:

生成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’;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值