Dima Dz
Dima Dz

Reputation: 538

Fail to run mysql script for other user than root

I have mysql installed on ubuntu server. There is a mysql script that has a select statement in it. I want to output the result of this select into .csv file.

If I run the following command

mysql -u root -pTHIS_IS_PASS MY-SCHEMA < /home/me/script.sql

things work out beautifully. I, however, I run

mysql -u OTHER-USER -pTHIS_IS_PASS MY-SCHEMA < /home/me/script.sql

I get this error:

ERROR 1045 (28000) at line 7: Access denied for user 'OTHER-USER'@'localhost' (using password YES)

I have no escaping characters in the password of OTHER-USER.

How can I fix this?

Upvotes: 0

Views: 66

Answers (1)

Dima Dz
Dima Dz

Reputation: 538

Found out the solution myself: I needed to grant FILE permission to the OTHER-USER.

GRANT FILE ON *.* TO 'OTHER-USER'@'localhost';

Don't forget that file permission is granted not to just one schema, but to the whole mysql.

Upvotes: 1

Related Questions