Joinutility seperatorLogin utility separator Infobright.com
   
 
Enable MySQL Logging
Posted: 05 June 2009 02:45 PM   Ignore ]  
Member
Avatar
RankRankRank
Total Posts:  160
Joined  2009-04-01

If you are having trouble enabling query logging then try the following command;

mysqlshow tables from mysql like '%log';
+------------------------+
Tables_in_mysql (%log) |
+------------------------+
general_log            
slow_log               
+------------------------+
2 rows in set (0.00 sec

If you don’t see these tables then you will need to create them manually using the following DDL;

CREATE TABLE `general_log` (
   `
event_timetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
 CURRENT_TIMESTAMP
,
   `
user_hostmediumtext,
   `
thread_idint(11) DEFAULT NULL,
   `
server_idint(11) DEFAULT NULL,
   `
command_typevarchar(64) DEFAULT NULL,
   `
argumentmediumtext
 
ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
CREATE TABLE `slow_log` (
   `
start_timetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
 CURRENT_TIMESTAMP
,
   `
user_hostmediumtext NOT NULL,
   `
query_timetime NOT NULL,
   `
lock_timetime NOT NULL,
   `
rows_sentint(11NOT NULL,
   `
rows_examinedint(11NOT NULL,
   `
dbvarchar(512) DEFAULT NULL,
   `
last_insert_idint(11) DEFAULT NULL,
   `
insert_idint(11) DEFAULT NULL,
   `
server_idint(11) DEFAULT NULL,
   `
sql_textmediumtext NOT NULL
 
ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'

Once you start, you may find tremendous value from the SQL logs.

Profile
 
Posted: 07 July 2009 01:34 PM   Ignore ]   [ # 1 ]  
Sr. Member
Avatar
RankRankRankRank
Total Posts:  738
Joined  2008-08-18

Thanks, Bob.

How does one enable/start logging with these tables?  And where/how can the logs be viewed?

Thanks, again.  This is very helpful.

Signature 
Profile
 
Posted: 07 July 2009 05:57 PM   Ignore ]   [ # 2 ]  
Member
Avatar
RankRankRank
Total Posts:  160
Joined  2009-04-01

Logging should be enabled by default.

But if you need to create the tables manually, then you will also need to bounce the server to start logging.

Regards, Bob

Profile
 
Posted: 07 July 2009 06:21 PM   Ignore ]   [ # 3 ]  
Sr. Member
Avatar
RankRankRankRank
Total Posts:  738
Joined  2008-08-18

Thanks, Bob.

Once I added the two tables I bounced the server and saw that session information was being logged to the files already present in the /etc/my-ib.cnf file.

(excerpted from /etc/my-ib.cnf)

# The MySQL server
[mysqld]
basedir 
= /usr/local/infobright
datadir 
= /usr/local/infobright/data
log
-error = /usr/local/infobright/data/bh.err
log
-output FILE
log 
= /usr/local/infobright/data/general_query.log # ADD FOR GENERAL QUERY LOGGING
log_slow_queries = /usr/local/infobright/data/slow_query.log # ADD FOR SLOW QUERY LOGGING 
[root@localhost data]# ls -l *.log
-rw-rw---- 1 mysql mysql  210 Jul  7 16:20 brighthouse.log
-rw-rw---- 1 mysql mysql 2018 Jul  7 16:25 general_query.log
-rw-rw---- 1 mysql mysql  844 Jul  7 16:24 slow_query.log 
Signature 
Profile