Hi:

First, I'm a PHP programmer and not a MySQL guru.

Second, I usually can get MySQL to do anything I want -- however, this OUTFILE thing has me stumped.

My mission is to simply backup a database and do it through PHP and not via a command line -- I don't have access to the server shel -- this is a hosted account. Please don't tell me how to use the command line to solve this problem.

Here's what I've done and it illustrates the problem:

After establishing a successful connection to the database, I can execute queries like the following --

[1]

$query = "SELECT * FROM users WHERE id='113' ";
$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));
$row = mysql_fetch_array($result);
$login = $row['login'];

-- with no problems.

However, if I try:

[2]

$file = '/home/mydomain/public_html/db-dump/tmp/db.txt';
$query = "SELECT * FROM users INTO OUTFILE '$file' ";
$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));

Where the 'tmp' directory has permissions set to 0777.

I receive the following error:

   "Access denied for user 'mydomain_user'@'localhost' (using password: YES)"

Normally, that type of error would be generated by a username/password problem. However, the code shown in [1] works while the code shown in [2] does not work and both segments of code are in the same script with an established connection.

My investigation reading through the MySQL manual leads me to:

http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html#priv_file

It states that I must have FILE permissions to read/write files on the server host to use OUTFILE.

So, my question is "How do I set the FILE permissions for a MySQL query?"

Many thanks for any answer or clarification.

Cheers,

tedd

PS: I asked a similar question to the PHP list, but they didn't couldn't help me.
--
-------
http://sperling.com/
_______________________________________________
New York PHP Community MySQL SIG
http://lists.nyphp.org/mailman/listinfo/mysql

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to