Solved

log an array of database queries, record to txt

Posted on 2014-03-23
6
218 Views
Last Modified: 2014-04-01
http://www.experts-exchange.com/Database/MySQL/Q_28395289.html

part1:
only want to log queries from an array of databases (not db:mysql, because there are too many results)

part2:
want to log queries to .txt file  (do I need to change permissions to 777)
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 50

Expert Comment

by:Steve Bink
ID: 39959050
Part1: This is not possible at the MySQL level.  The config setting there is for the service as a whole.  If you want to capture only queries to certain databases, you'll need to build an abstraction layer in your application to handle it.

Part2: In the previous question, you stated you are using Windows, so the 777 permission setting does not really apply.  The slow log file you want to use should be owned by the same user used to run the MySQL service, and be writable by that user.
0
 

Author Comment

by:rgb192
ID: 39964934
you stated you are using Windows, so the 777 permission setting does not really appl
I do not understand windows permissions so I use unix based cygwin to set to 777

The slow log file you want to use should be owned by the same user used to run the MySQL service, and be writable by that user.
How
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 39965046
Generally, you can just set the filename to be used in the MySQL configuration, and it will be created by the service.  If the file exists, delete it and it will be recreated.

You can check the status of your slow query log by using this SQL command:
show variables like '%slow_query%';

Open in new window


If your log is enabled, but nothing is being recorded, then you haven't had any executed queries matching the limits.  There are a few limits you can configure.  See https://dev.mysql.com/doc/refman/5.6/en/slow-query-log.html for more information on how the engine determines whether or not to log any given query.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:rgb192
ID: 39966812
show variables like '%slow_query%'

slow_query_log      ON
slow_query_log_file      C:\wamp{some-unreadble-character}in\mysql\mysql5.6.12\data\mysql low_query_log_file.txt


the table adds rows but the file stays the same size
C:\wamp\bin\mysql\mysql5.6.12\data\mysql\slow_query_log_file.txt

I think the query is returning incorrect file location

how to change file location

I already have
[mysqld]
port=3306
slow_query_log=1
log-output = TABLE,FILE
slow_query_log_file=C:\wamp\bin\mysql\mysql5.6.12\data\mysql\slow_query_log_file.txt
long_query_time=0
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 39969142
Change your setting as shown below and restart the service:
slow_query_log_file=C:\\wamp\\bin\\mysql\\mysql5.6.12\\data\\mysql\\slow_query_log_file.txt

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 39970871
after restart much data is written to
slow_query_log_file=C:\\wamp\\bin\\mysql\\mysql5.6.12\\data\\mysql\\slow_query_log_file.txt

thanks
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question