Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
407 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 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