• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux How to fix mysql "Can't create/write to file" "(Errcode: 13)" Error on CENTos

manuel220

New Member
Joined
Jan 20, 2009
Messages
67
Reaction score
1
Well, I got this issue on my server, so I'm gonna post the solution here in case someone else need it.

I was running this command:

Code:
 mysql --user=otserv --password=otservpass -D armada -e "select * from concursos INTO OUTFILE '/tmpArmada/concursos.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n'"

and getting error:

Code:
ERROR 1 (HY000) at line 1: Can't create/write to file '/tmpArmada/concursos.txt' (Errcode: 13)


In CentOS there is a Enhanced Security system called SELinux, so we need to set special settings on the specific folder, in this case: /tmpArmada/ so:

Code:
#chown mysql:mysql /tmpArmada
#chcon -Rv --type=tmp_t /tmpArmada
context of /tmpArmada changed to root:object_r:tmp_t

then you can verify the change using the command: ls -ltrZ

Code:
# ls -ltrZ
drwxrwxrwt  [B]mysql [/B][B]mysql [/B]root:object_r:[B]tmp_t[/B]              tmpArmada


So what we did was set the type: tmp_t to the folder. And now mysql is able to write on it
 
Back
Top