Febriyanto Nugroho Febriyanto Nugroho - 2 years ago 86
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?

Answer Source

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';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download