MySQL - SELECT INTO (SQL Error (1045): Access denied for user 'test'@'%' (using password: YES))

366 Views Asked by At

When I try to export records using the below query, I am getting an error

SELECT ID, Name FROM Emp 
INTO OUTFILE 'C:/temp/hash.csv' 
FIELDS ENCLOSED BY '"' 
TERMINATED BY ';' 
ESCAPED BY '"' 
LINES TERMINATED BY '\r\n';

Error:

SQL Error (1045): Access denied for user 'test'@'%' (using password: YES)

I am getting same error while running the below:

GRANT FILE ON *.* TO 'test';

SHOW VARIABLES LIKE "secure_file_priv";
secure_file_priv:  /tmp/

I want to run a stored procedure to export the records through a .Net application. I am expecting the output file to be created on the windows computer. The MySQL instance is running on AWS.I think the "secure_file_priv" path is causing the issue. The same query is working in another MySQL instance that is running on windows server.

Thank you.

1

There are 1 best solutions below

0
On

You need to out file the csv file to aws instance first, and then download it to your windows computer.