[MySQL] How to Solve ERROR 1045 (28000): Access denied for user

Tadashi Shigeoka ·  Sat, September 24, 2011

When I tried to export to a CSV file in MySQL, the following error occurred:

mysql> select * from users into outfile "./users.csv" FIELDS TERMINATED BY ',';
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)

It seems the MySQL user didn’t have FILE handling permissions, so it couldn’t output to the CSV file.

MySQL

How to Solve ERROR 1045 (28000): Access denied for user

By granting permissions with a GRANTS query, you can enable file output via queries.

GARANTS FILE ON *.* TO username@localhost;

That’s all.

Reference Information

That’s all from the Gemba.