Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to create a csv export of data from mysql using the following query:

SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM getfreepellets WHERE 1

And I get the following error:

#1045 - Access denied for user '[username]'@'localhost' (using password: YES)

(removed username but it's the right one)

How would I go about granting access to this user to create a file on the server?

Edit:

I changed the first line to be my exact home path, and received the same error.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

first you must define what your database is with:

use database_name;

Then you can run your query.

If that still not working it is because you create those but you havent defined access to it for that given user.

GRANT ALL ON database_name.* TO 'someuser'@'somehost';

You can read more about the Grant usage at http://dev.mysql.com/doc/refman/5.1/en/grant.html

share|improve this answer
    
Thanks. Turns out BlueHost can't grant permissions to do this. Sadly. –  PJ. Aug 7 '10 at 18:34
    
Well you can do it yourself from the cPanel under database menu, First you create a database with it then you assign a user to it, further in you can use the wizard from the database to run all steps needed. That's ofc if you have access to the cpanel within your hosting plan. –  Prix Aug 7 '10 at 18:44
#1045 - Access denied for user '[username]'@'localhost' (using password: YES)

That error has nothing to do with file or directory permissions. That's MySQL telling you that the MySQL logon credentials you used are incorrect for that query. This may be because, as Prix pointed out, you haven't specified the database to use.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.