From: Simon J Welsh on
On 14/08/2010, at 9:59 AM, Ashley Sheridan wrote:

> I've only ever done something like this via the command line. Having
> said that, could you maybe pass a command line string to exec().
> Something like (untested):
>
> echo 'password' | mysql -u root -p < query
>
> I believe that is the right sort of thing, but I've never quite done it
> all as a single statement like this before, I've always tended to type
> in things on a line-by-line basis.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

That wont work, as pipping just passes stdout to stdin, which mysql grabs queries to run from (which you're using file redirection for).

I know of someone that wanted to do something similar, but didn't want to use a plaintext password in the command (shared host security and that sort of stuff), so they got PHP to generate a defaults file with the user/password and passed that instead (--defaults-extra-file)

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e