Solved

mysql how can I execute a query, direct it to an output file, and not have it include in the output file the query I ran to get the data?

Posted on 2010-09-22
5
399 Views
Last Modified: 2012-05-10
I am developing a mysql report and I need to know direct it to an output filewithout the output file including the query I ran to generate the data?  Currently, even if I run it in silent mode and redirect it with the tee command, it sill places in the output file the query I ran.  I don't want that to show up in the report.  Does anyone have any ideas?
0
Comment
Question by:navajo26354
5 Comments
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 500 total points
ID: 33736309
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 33736319
mysql -uUSER -pPASS databasename -e  "YOUR QUERY" > outputfile.txt
0
 
LVL 4

Expert Comment

by:max-hb
ID: 33736333
Hi!
Assuming you are using Linux/Unix try this:

mysql -insert-your-options < query.sql > outfile.txt

Replace "-insert-your-options" with any information needed to connect to your database, eg. "-u root -p secrecy -h localhost" etc.

CU
 maxhb
0
 
LVL 1

Expert Comment

by:eekygeeky
ID: 33736341
To the best of my knowledge, there's no way to do that . You can output the data to a .csv file and anything you use to read the .csv file will ignore the SELECT statement because it won't output as comma seperated. in a .txt file, you will always see the query.

-tee just forks the output so it goes two places at once, like on the screen and to a log file simultaneously.

Most websitesand repotr generating tools  handle this with PHP or something , that can be used to automatically look at the query results and generate a pretty looking webpage or Word document or something. Excel can import .CSVs directly if that's any help.
0
 
LVL 6

Expert Comment

by:bimal_linux
ID: 33741226
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now