Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

MySQL Problem


ghost's Avatar
0 0

this is my problem (maybe is easyly solvable): I'm trying a query like this: markupSELECT "test" INTO DUMPFILE "/var/www/images/test.tst" But i don't have permission to write into that file:

MySQL said: #1 - Can't create/write to file '/var/www/images/test.tst' (Errcode: 13)

I've chmodded the dir to 777 and chowned it to mysql.mysql:

chown: drwxrwxrwx 2 mysql mysql 4096 2009-02-25 17:54 images stat: File: `images/' Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 801h/2049d Inode: 1401177 Links: 2 Access: (0777/drwxrwxrwx) Uid: ( 112/ mysql) Gid: ( 125/ mysql) Access: 2009-02-25 17:54:33.000000000 +0100 Modify: 2009-02-25 17:54:33.000000000 +0100 Change: 2009-02-25 17:54:43.000000000 +0100

Can someone help with this?


ghost's Avatar
0 0

ah, another thing, if i use markupSELECT "test" INTO DUMPFILE "/tmp/test.tst" it works.


spyware's Avatar
Banned
0 0

Did you chmod the dir + all the files in there? Try chmodding the file you're writing to.


ghost's Avatar
0 0

Yes, but i got this error:

ERROR 1086 (HY000): File '/var/www/images/file.txt' already exists … Anyway, i don't need to append to a file, i need to write a new file with some info…


ghost's Avatar
0 0

I got the same error :(


ghost's Avatar
0 0

what i would do is to allow mysql to write into /var/www/images/


ghost's Avatar
0 0

mysqld should be running as www-data, so use:

chown -R www-data.www-data /var/www/images/

and see what happens then?


ghost's Avatar
0 0

jjbutler88 wrote: mysqld should be running as www-data, so use:

chown -R www-data.www-data /var/www/images/

and see what happens then?

I had already tried that way, but unfortunately it doesn't work


ghost's Avatar
0 0

Yo guys, got it! :D

This is my solution:

  1. edit "/etc/mysql/my.cnf" markup# vi /etc/mysql/my.conf

  2. change the "tmpdir" variable to "/var/www/images"

  3. if u use apparmor edit "/etc/apparmor.d/usr.sbin.mysqld" markup# vi /etc/apparmor.d/usr.sbin.mysqld

  4. add this lines:

/var/www/images/** rwk,```
5. restart mysql and apparmor with ```markup/etc/init.d/mysql reload && /etc/init.d/apparmor reload```

If u have a better solution, please let me know.

ghost's Avatar
0 0

good job Cyph3r ;)


ghost's Avatar
0 0

thanks man :)