I have a python (3.6 anaconda distribution) scrip on Centos 7 which at some point executes a simple query of the following structure

import MySQLdb

cursor = cnn.cursor()  # cnn is the open connection to MySQL db
cursor.execute(strSQL) # cursor is the active cursor of cnn, 
                       # and strSQL is a simple SELECT query  

The python script is being called from PhP (via exec) for data processing.

The cursor execute statement above throws the following error

Can't create/write to file '/tmp/MYC8vAAs' (Errcode: 13 - Permission denied)

All these programs work with no problems when called from the terminal window or locally on Ubuntu (VM on widows). I have very little expertise of system administration, but from what I've googled so far, all arrows are pointing to correct permission of /tmp folder (like here for example), but in my case the permissions are as follows


and I cannot think of any reason as why this is happening. Your insights on this would be most appreciated.


The permissions on your /tmp folder are wrong. chmod 1777 /tmp should fix that.

  • thanks for your reply. I tried that, the permission became drwxrwxrwt, but nothing changed, still get the very same error. – Hayk Jul 25 '18 at 17:44
  • @Hayk You should restart MySQL. And you should probably try to figure out how /tmp got its wrong permissions. – Michael Hampton Jul 25 '18 at 18:32
  • @MichaelHampton, thanks for the comment. I tried to restart MySQL with systemctl restart mysqld but it did not work and now MySQL is down. What I see from the MySQL logs is the following mysqld: Can't create/write to file '/tmp/iblbBbVr' (Errcode: 13 - Permission denied) tmp has all permissions, but MySQL fails to write on it. What can I do now? – Hayk Jul 25 '18 at 19:05
  • @Hayk How did /tmp get wrong permissions to begin with? – Michael Hampton Jul 25 '18 at 19:19
  • well, I don't remember that I changed it by hand. All was working fine until recently, and I still cannot restart MySQL. /tmp now has the correct permissions following the comments above, but then how can it be that MySQL still cannot write there ? Is there anything else I'm overlooking ? – Hayk Jul 25 '18 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.