?
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
Medium Priority
?
406 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
[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
5 Comments
 
LVL 15

Accepted Solution

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

Expert Comment

by:K V
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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