Any ideas?
SELECT * INTO OUTFILE '/home/myacnt/docs/mysqlCSVtest.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '*'
LINES TERMINATED BY '\n'
FROM tbl_property
WHERE managerGroupID = {$managerGroupID}
Error:
Access denied for user 'asdfsdf'@'localhost' (using password: YES)
As @fijaaron says,
GRANT ALL
does not implyGRANT FILE
GRANT FILE
only works with*.*
So do
Try executing this SQL command:
It seems that you are having issues with connecting to the database and not writing to the folder you’re mentioning.
Also, make sure you have granted
FILE
to user'asdfsdf'@'localhost'
.Honestly I didnt bother to deal with the grants and this worked even without the privileges:
Since cP/WHM took away the ability to modify User privileges as root in PHPMyAdmin, you have to use the command line to:
Step 2 is to allow that user to dump a file in a specific folder. There are a few ways to do this but I ended up putting a folder in :
and
That allows the mysql user to write the file. As previous posters have said, you can use the MySQL temp folder too, I don't suppose it really matters but you definitely don't want to make it 0777 permission (world-writeable) unless you want the world to see your data. There is a potential problem if you want to rinse-repeat the process as
INTO OUTFILE
won't work if the file exists. If your files are owned by a different user then just trying tounlink($file)
won't work. If you're like me (paranoid about 0777) then you can set your target directory using:just prior to doing the SQL command, then
immediately after, followed by
unlink(file)
to delete the file. This keeps it all running under your web user and no need to invoke the mysql user.