在 Centos 7 上 python 调用 MySQL 时在 /tmp 中写入权限错误

在 Centos 7 上 python 调用 MySQL 时在 /tmp 中写入权限错误

我有一个python(3.6 anaconda发行版)脚本Centos 7在某个时候执行以下结构的简单查询

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  

该 Python 脚本正在从 PhP 调用(通过执行) 进行数据处理。

光标执行上面的语句会引发以下错误

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

所有这些程序在从终端窗口或在 Ubuntu 本地(Windows 上的 VM)调用时都可以正常工作。我对系统管理的专业知识很少,但从我到目前为止在 Google 上搜索的内容来看,所有箭头都指向正确的权限/tmp文件夹(如这里例如),但就我而言,权限如下

drwxrwxrwx.  

我无法想出发生这种情况的任何原因。非常感谢您的见解。

答案1

您的文件夹的权限/tmp错误。 chmod 1777 /tmp应该修复它。

相关内容