List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:February 6 2004 3:04am
Subject:Re: Bash script to MySql
View as plain text  

Scott Haneda wrote:

> on 02/05/2004 07:29 AM, Michael Stassen at Michael.Stassen@stripped
> wrote:
> 
> 
>>Also, you need the FILE privilege to SELECT INTO OUTFILE.
>>
>>Alternatively, you could simply redirect output to a file.
>>
>>mysql dbname -e "SELECT serial FROM serials" >/path/to/outfile
>>
>>In this case, the file is written by the user running the cron job, so
>>that user, not mysql, needs permission to write.
> 
> 
> Great idea, how do I get a \r style dump with none of the pretty wrappers
> around it.?

-B or --batch: prints rows tab-separated and turns off the borders
-N or --skip-column-names: leaves out the header row

So, you probably want

  mysql dbname -B -e "SELECT serial FROM serials" >/path/to/outfile

or

  mysql dbname -B -N -e "SELECT serial FROM serials" >/path/to/outfile

>>Finally, I think it's important to point out that putting -ppass or
>>--password=pass on the command line is insecure.  Any user who runs ps
>>at the right moment can see the password.  The preferred way to do this
>>is to put the password in the client section of the user's .my.cnf file.
>>See <http://www.mysql.com/doc/en/Option_files.html> for more.
> 
> 
> Thanks, great info, I will read into this.

I didn't mention it, but you can also put the mysql username in the 
.my.cnf client section, if it's different from the unix username. 
That's documented on the same manual page I already pointed you to.

Michael

Thread
column being created as varchar() when char() requested.Philip Walden3 Feb
  • Re: column being created as varchar() when char() requested.Michael Stassen3 Feb
    • Re: column being created as varchar() when char() requested.Philip Walden3 Feb
      • Re: column being created as varchar() when char() requested.Michael Stassen3 Feb
        • Re: column being created as varchar() when char() requested.Philip Walden4 Feb
          • Monthly reportingScott Haneda4 Feb
            • Bash script to MySqlScott Haneda4 Feb
              • Re: Bash script to MySqlHassan Schroeder4 Feb
                • Re: Bash script to MySqlBernd Tannenbaum4 Feb
                  • RE: Bash script to MySqlRussell Horn4 Feb
                  • Re: Bash script to MySqlScott Haneda5 Feb
                    • Re: Bash script to MySqlBernd Tannenbaum5 Feb
                    • Re: Bash script to MySqlMichael Stassen5 Feb
                      • Re: Bash script to MySqlScott Haneda6 Feb
                        • Re: Bash script to MySqlMichael Stassen6 Feb
              • Re: Bash script to MySqlDuncan Hill4 Feb
              • User Defined FunctionBácskai Gergő" 4 Feb
          • Re: column being created as varchar() when char() requested.Michael Stassen4 Feb
            • Re: column being created as varchar() when char() requested.Philip Walden5 Feb
              • Re: column being created as varchar() when char() requested.Michael Stassen5 Feb
                • Re: column being created as varchar() when char() requested.Philip Walden6 Feb
                  • Re: column being created as varchar() when char() requested.Michael Stassen6 Feb
  • Re: column being created as varchar() when char() requested.Martijn Tonies4 Feb
RE: Bash script to MySqlDan Muey4 Feb