I'm trying to access MySQL and execute multiple large queries with a "here document" in a shell script.
Running the following command works perfectly fine:
/usr/bin/mysql -u username -ppassword -h localhost database
Running this command results in an Access Denied error:
/usr/bin/mysql -u username -ppassword -h localhost database << EOF
--MySQL queries here
EOF
This is the error I receive:
ERROR 1045 (28000) at line 3: Access denied for user 'username'@'localhost'
With the only difference in the two methods being the << EOF
, why am I all of a sudden receiving an error?
So please show us the query from line 3. Maybe you have only some permissions or have no permissions to some tables.
You need FILE privilege to import data from file. This is probably missing for your
username
.See MySQL LOAD DATA INFILE user privilege settings
For Ubuntu (12.04 tested) users is not enough granting permissions for MySQL user.
This problem is more complex and related to AppArmor MySQL LOAD DATA INFILE - AppArmor issue