Re: It's Friday (a MySQL Question)
| From: | Ashley Sheridan | Date: | Fri, 13 Aug 2010 21:59:47 +0000 |
| Subject: | Re: It's Friday (a MySQL Question) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307444@lists.php.net to get a copy of this message | ||
On Fri, 2010-08-13 at 17:48 -0400, tedd wrote:
> Hi gang:
>
> Normally if I want to dump a MySQL database, I read the database via
> a PHP script (i.e., list tables and fetch rows) and save the results
> as a text file -- after which I download the file -- it's not a big
> deal.
>
> However while I was doing my daily read of the MySQL Manual, namely:
>
> http://dev.mysql.com/doc/refman/5.0/en/select.html
>
> I came across this statement:
>
> SELECT * FROM table_reference INTO OUTFILE 'file_name'
>
> It looked to be bit simpler/shorter than my code, so I tried it. But
> it reports:
>
> Access denied for user 'me'@'localhost' (using password: YES).
>
> I suspect that the "access being denied" is because MySQL doesn't
> have permission to create the output file. The MySQL manual reports:
> 1) that a file cannot be present; 2) AND MySQL must have file
> privileges to create the file -- but I don't know how to set that up.
>
> So, has anyone got this to work? If so, how did you do it? If at all
> possible, please provide code (MySQL/PHP) and not command-line
> statements.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com/
>
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