Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on a local windows machine. The MySQL DB is on a CentOS machine elsewhere on the same local network. I want to output the results of the query that I'm typing directly into Putty into an Excel (or csv) file elsewhere on the local network. How would I do this?

I tried something like

mysql> select * from table > \\server\my_documents\output.csv

but no luck.

share|improve this question

Looks like you're starting a mysql interactive session. Instead, you'll want to execute the SQL from a text file, i.e.

mysql database_name < input.script.sql > output.file

You'll want to ensure that your SELECT statement outputs something usable, so something like what's mentioned in this answer on stackoverflow. Note that that answer already has the outfile specified, so you wouldn't need the redirect as shown above . . .

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.