Febriyanto Nugroho Febriyanto Nugroho - 10 months ago 41
SQL Question

How to create/write a file using exp() in mySQL

in mysql prompt i want try to create/write a file using following command :

mysql> select exp(~(select*from(select 'hello')x)) into outfile '/home/febri/meh.txt';

but I get an error :

ERROR 1 (HY000): Can't create/write to file '/home/febri/meh.txt' (Errcode: 13)

in addition to the above command is there any other solution?


The fact that you are using EXP() doesn't have anything at all to do with the error. The problem is purely a permission issue. You are tring to write to /home/febri/meh.txt as the mysql user. But mysql user cannot access your home directory. Use /tmp/meh.txt instead.

select exp(~(select*from(select 'hello')x)) into outfile '/tmp/meh.txt';