I am trying to output the data from an MySQL table to a file but getting permission errors:
$ pwd
/home/dotancohen
$ mkdir in
$ chmod 777 in/
$ mysql -ugs -p
mysql> USE someDatabase;
mysql> SELECT * FROM data INTO OUTFILE '/home/dotancohen/in/data.csv';
ERROR 1045 (28000): Access denied for user 'gs'@'localhost' (using password: YES)
mysql>
If the directory in question is chmodded to 777, then why cannot the MySQL user write the file? Interestingly enough, I cannot write to /tmp/ either.
EDIT: It looks like the DB user has the proper MySQL permissions:
mysql> show grants;
+----------------------------------------------------------------------------------+
| Grants for gs@localhost |
+----------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'gs'@'localhost' IDENTIFIED BY PASSWORD 'somePassword' |
| GRANT ALL PRIVILEGES ON `gs\_%`.* TO 'gs'@'localhost' |
+----------------------------------------------------------------------------------+
2 rows in set (0.01 sec)
inis pointless if MySQL can't accessdotanchoen. In other words, the safety depost box in the bank vault can be left wide open, but if the bank vault door is locked, you ain't getting into the box. Yourgsuser must also have the mysqlFILEprivilege to actually execute that query. – Marc B Apr 24 '12 at 2:39SELECTpermissions. I often browse the database as this user. – dotancohen Apr 24 '12 at 3:42FILEprivilege as described by MySQL docs. – Mike Purcell Apr 24 '12 at 4:01