0
use people;
SELECT 'first' UNION SELECT first from e where skills regexp "javapl" INTO OUTFILE '/home/ankit/csv/tablename.csv' 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY '\n';

this runs without problem to /var/tmp folder but other folders gave error:13 can't write please help

3
Contributors
6
Replies
26
Views
3 Years
Discussion Span
Last Post by ankit1122
0

It is probably a permission issue

Privileges should be :
drwxrwxrwt
so anybody, including the "mysql" user, can use it. If is not like this you have to run this command from terminal:
chmod 0777 /home/ankit/csv

Hope this helps!

0

Hello,

You ca try to edit /etc/apparmor.d/usr.sbin.mysqld (sudo gedit /etc/apparmor.d/usr.sbin.mysqld) and add /home/ankit/csv/ and /home/ankit/csv/* near the bottom like so:

...
/usr/sbin/mysqld {
    ...
    /var/log/mysql/ r,
    /var/log/mysql/* rw,
    /home/ankit/csv/ r,
    /home/ankit/csv/* rw,
}

And then reload AppArmor.

sudo /etc/init.d/apparmor reload

0

The question comes down to who owns the directory that you are trying to write the file into. In this case you want it to write the a directory under /home/ankit called csv which probably looks like this:

[root@hpsrvr ~]# ls -lad /home/ankit/csv
drwxr-xr-x 2 ankit ankit 4096 Nov 22  2012 /home/ankit/csv

Now that you know that simply add the mysql user to that group (stored in the /etc/group file) and set the directory permissions to 775. To add the mysql user to the ankit group use:

usermod -a -G ankit mysql
chmod 755 /home/ankit/csv

And it should now look like this:

[root@hpsrvr ~]# ls -lad /home/ankit/csv
drwxrwxr-x 2 ankit ankit 4096 Nov 22  2012 /home/ankit/csv

Let us know how it goes.

0

still the same error

SELECT 'first'

UNION SELECT first from e INTO OUTFILE '/home/ankit/csv/h.csv' 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY '\n';
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.