Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 627071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:29:18+00:00 2026-05-13T19:29:18+00:00

I often work in command line mysql. A common need is to take a

  • 0

I often work in command line mysql. A common need is to take a query’s results and import them into a Numbers document (similar to an Excel document).

What is the fastest method for doing this?

Method 1: Select into outfile

You can select into an outfile directly from MySQL, but this takes several steps.

  1. export your query with all the necessary arguments to make it a CSV format, like FIELDS OPTIONALY ENCLOSED BY and DELIMITED BY.
  2. sftp into the server and grab the file
  3. delete the file from the server

Method 2: Copy/paste

I tend to do this method. For me it seems a little faster but that’s mostly because I don’t remember how to construct the SELECT INTO OUTFILE query from above and have to look it up.

  1. Copy/paste to a local text file
  2. Open in a text editor and replace | with ,
  3. Save as a CSV and open in Numbers.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:29:18+00:00Added an answer on May 13, 2026 at 7:29 pm

    How about this?:

    mysql -B -e “$MY_QUERY” > my_data.csv

    The output format is actually tab-separated rather than comma-separated
    but at least Excel and OpenOffice Calc automatically adapt to this.

    BTW, for convenience and to enable non-interactive execution of
    mysql commands, I strongly recommend setting up a secure ~/.my.cnf file
    (readable only by you) with entries like this:

    [client]
    user=YOUR_MYSQL_USER_NAME
    password=YOUR_MYSQL_PASSWORD
    host=YOUR_MYSQL_SERVER
    port=YOUR_MYSQL_SERVER_PORT
    WHATEVER_OTHER_OPTIONS_YOU_LIKE
    

    References:

    http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html

    –batch, -B

    Print results using tab as the column separator, with each row on a new line. With this option, mysql does not use the history file.

    Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the –raw option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our developers frequently work in large Visual Studio projects and we often run command-line
TL;DR Summary: I need a single command-line application which I can use to get
Quick bash/terminal question - I work a lot on the command line, but have
I often work on CSS files or other files that require twiddling numbers. I
I often work with multidimensional arrays whose array indices are generated from a complicated
I often work in Eclipse, but recently switched to TextMate, which is, in my
As a freelancer, I often work at companies who use Subversion repositories. It’d be
At my company, we develop our ASP.NET applications as websites and often just work
I often like to create backups when testing the software I work on, and
I work on applications developed in C#/.NET with Visual Studio. Very often ReSharper, in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.