- 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';
- Switch the engine from CSV to MyISAM. To switch the engine from CSV to MyISAM, execute the following commands (the default is ENGINE=CSV).
- Check the definition of "mysql.general_log" table. Execute the following SQL command:
mysql> show create table mysql.general_log; +-------------+----------------------------------------------------------------- -----------------------------------------+ | 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; +---------------------+------------------------------------+-----------+-------- ---+--------------+----------------------------------+ | event_time | user_host | thread_id | server_ id | command_type | argument | +---------------------+------------------------------------+-----------+-------- ---+--------------+----------------------------------+ | 2009-07-29 16:44:23 | root[root] @ localhost [127.0.0.1] | 1 | 0 | Connect | root@localhost on mysql | | 2009-07-29 16:44:23 | root[root] @ localhost [127.0.0.1] | 1 | 0 | Query | select @@version_comment limit 1 | | 2009-07-29 16:44:37 | root[root] @ localhost [127.0.0.1] | 1 | 0 | Query | show create table general_log | | 2009-07-29 16:45:19 | root[root] @ localhost [127.0.0.1] | 1 | 0 | Query | set global general_log='OFF' | | 2009-07-29 16:46:18 | root[root] @ localhost [127.0.0.1] | 1 | 0 | Query | select * from mysql.general_log | +---------------------+------------------------------------+-----------+-------- ---+--------------+----------------------------------+ 5 rows in set (0.00 sec)
- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Comments
Post a Comment