MySQL临时表创建出错(OS errno 13 - Permission denied)

一个客户向我抱怨:在MySQL查询小表没有问题,查询大表出错,下面是他发给我的出错的部分截屏(客户的表名被我隐藏了)。

在这里插入图片描述

这里的给出的信息已经比较明显了,是向/tmp目录中创建临时表失败(临时表的路径是由系统变量tmpdir决定的,默认在/tmp目录中),小表不需要用到临时表就没有问题,我登录上去检查一下MySQL的错误日志,发现有下面的记录:

2024-01-27T09:31:14.059966Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ib9IqGPN' (OS errno 13 - Permission denied)
2024-01-27T09:31:14.060056Z 0 [ERROR] [MY-012792] [InnoDB] Cannot create temporary merge file
2024-01-27T09:32:22.698498Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ibuFD5pG' (OS errno 13 - Permission denied)
2024-01-27T09:32:22.698617Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ibJyUu0y' (OS errno 13 - Permission denied)
2024-01-27T09:32:22.698786Z 0 [ERROR] [MY-012792] [InnoDB] Cannot create temporary merge file
2024-01-27T09:32:22.698783Z 0 [ERROR] [MY-012792] [InnoDB] Cannot create temporary merge file

24-01-27T09:30:06.361749Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ibivRI0I' (OS errno 13 - Permission denied)
2024-01-27T09:30:06.361920Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ibx78TGm' (OS errno 13 - Permission denied)
2024-01-27T09:30:06.361864Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/ibdcjrzB' (OS errno 13 - Permission denied)
2024-01-27T09:30:06.361955Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/tmp/iblFGa8t' (OS errno 13 - Permission denied)

看来是/tmp目录的权限出了问题,检查一下:

oracle@Scott ~$ ll -ld /tmp
drwxrwxrwt. 11 root root 4096 Jan 29 09:22 /tmp
oracle@Scott ~$

[root@oracle data]# ll -ld /tmp
drwxr-xr-x. 70 root root 630784 Jan 29 09:40 /tmp

发现权限不足,而且居然没有粘滞位(Sticky bit),粘滞位是Unix文件系统权限的一个旗标。最常见的用法在目录上设置粘滞位,如此以来,只有目录内文件的所有者或者root才可以删除或移动该文件。如果不为目录设置粘滞位,任何具有该目录写和执行权限的用户都可以删除和移动其中的文件。实际应用中,粘滞位一般用于/tmp目录,以防止普通用户删除或移动其他用户的文件。使用下面的命令对tmp目录进行修改:

sudo chmod 1777 /tmp 

然后故障排除😀

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

姚远Oracle ACE

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值