my cron jobs can not use SELECT INTO OUTFILE syntax?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

just quick wrote this shell script to be called by cron:


$link = mysql_connect('localhost', 'xxxxxx', 'xxxxxxx');
if (!$link) {
    die('Not connected : ' . mysql_error());

// make foo the current db
$db_selected = mysql_select_db('thesecondroad', $link);
if (!$db_selected) {
    die ('Can't use foo : ' . mysql_error());

$fileName = "community_post" . time() . ".sql";
$query = "SELECT * FROM community_post INTO OUTFILE '/home/lkrubner/
$fileName'  ";
//$query = "SELECT * FROM community_post  ";
$result = mysql_query($query);

//$row = mysql_fetch_assoc($result);
echo mysql_error();


Do you see the query that I've got commented out? If I uncomment it,
and instead comment the other query, then everything works fine - I
can also uncomment the line with I get a row returned from the results
and I can use print_r to make an array appear at the command line.

But this query:

$query = "SELECT * FROM community_post INTO OUTFILE '/home/lkrubner/
$fileName'  ";

gets me this error:

Access denied for user 'user_road'@'%' (using password:

Mind you, I'm using the same password and username in both cases, as
you can plainly see.

So is it that the user does not have these permissions? Do I need to
login to mysql as root and add these permissions for these users?

And what forum do I go to to ask how to reset the root Mysql password?
I don't think I ever had it. I only have the root username/password
for the server.

-- lawrence

Re: my cron jobs can not use SELECT INTO OUTFILE syntax?

Quoted text here. Click to load it
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected
rows to a file. The file is created on the server host, so you must have the
FILE privilege to use this syntax. file_name cannot be an existing file,
which among other things prevents files such as /etc/passwd and database
tables from being destroyed. As of MySQL 5.0.19, the
character_set_filesystem system variable controls the interpretation of the

Quoted text here. Click to load it

that answer is also somewhere in
or on one of the hits from


Re: my cron jobs can not use SELECT INTO OUTFILE syntax?

lawrence k wrote:
Quoted text here. Click to load it


First of all, this is not a forum.  This is a newsgroup.  Google Groups
is just a poor interface to usenet.  Get yourself a good newsgroup
reader and you'll be in a lot better shape.

And mysql questions are better asked in a mysql newsgroup.  Did you try
looking for one?  It didn't take long to find comp.databases.mysql, for

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline