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 800611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:18:56+00:00 2026-05-14T23:18:56+00:00

at the moment I’m writing a simple script in ksh who should take some

  • 0

at the moment I’m writing a simple script in ksh who should take some strings from a DB and list them on the shell. This is how it should work:

  • Query the DB for all the datas
  • Export them to a text file
  • Using awk to show the different columns

The problem is that two fields of the table I’m querying contain sentences. So awk, obviously, “thinks” that the white spaces between the different words are separators between columns, so I came up with the following solution:

  • SELECT * INTO OUTFILE “output” FIELDS TERMINATED BY ‘,’ FROM table
  • Using awk to list the results (obviously the separator now is ‘,’)

But here I have another issue, though I’ve

  • Granted the FILE privilege to the mysql user I’m using
  • Gave to mysql 777 on the directory where it should write

Even so I’m receiving the following error:

‘path’: Can’t create/write to file ‘file’ (Errcode: 13)

Frustrated by this I’ve started surfing the web to find an answer, and I found an “incomplete” one. In a certain site they suggest to:

  • chown root:root /tmp

  • chmod 1777 /tmp

  • /etc/init.d/mysqld start

I thought that, if this solution works fine on /tmp then there shouldn’t be any problem on any other directory I choose. Obviously I was totally wrong :). If the path I’m giving to the outfile option is /tmp/’file’ then there’s no problem, any other path returns me the previous error. So did I find a ‘solution’ to the problem? Well, yes but to use this script a someone have to:

  • Have a mysql user with the FILE privilege
  • Have the rights to ‘rm’ a file in /tmp (the output file of mysql is temporary)

And I don’t think this is sweet&nice. So what I’m asking you? The following:

  • How can I force mysql to write a file wherever I want?
  • Have you more viable and ‘sweet’ solution than mine to suggest me?

Ah, I’m using Ubuntu 10.4.
Thank you for any help.

  • 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-14T23:18:57+00:00Added an answer on May 14, 2026 at 11:18 pm

    A better solution is to redirect output:

    mysql --default-character-set=utf8 -uuser -ppass -s -e "SELECT * FROM mytable;" > results.txt
    

    Mind the -s option:

      -s, --silent        Be more silent. Print results with a tab as separator,
                          each row on new line.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.