Can't create/write to file '/tmp/MLjnvU95' (Errcode: 13 - Permission denied)
今天一个同事反馈往一个MySQL数据库导入数据时,报“ERROR 1 (HY000): Can't create/write to file '/tmp/MLjnvU95' (Errcode: 13 - Permission denied)”这样的错误,如下所示:
uery OK, 0 rows affected (0.03 sec)
ERROR 1 (HY000): Can't create/write to file '/tmp/MLjnvU95' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/MLPzmIbJ' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/MLdpJwKm' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/MLB7FTT0' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/ML1wcUAF' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/MLYjOzPk' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/ML7gi9z0' (Errcode: 13 - Permission denied)
ERROR 1 (HY000): Can't create/write to file '/tmp/ML6nezQG' (Errcode: 13 - Permission denied)
个人使用source script.sql导入数据时,也是遇到这个错误,如上截图所示。从这个错误提示,可以明显看出是MySQL没有权限对/tmp进行操作,
查看系统变量tmpdir,如下所示,tmpdir变量指定路径为/tmp
mysql> show variables like 'tmpdir';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| tmpdir | /tmp |
+---------------+-------+
1 row in set (0.00 sec)
[root@mylx01 ~]# ls -lh /tmp
total 20M
-rw-rw-r--. 1 root root 20M Nov 7 12:04 cccc_user.sql
-rw-r--r--. 1 root root 57 Nov 7 02:00 percona-version-check
-rw-------. 1 root root 2.0K Nov 2 21:38 tmpP4BN3H
-rw-------. 1 root root 2.0K Oct 31 21:40 tmpusdOhs
-rw-------. 1 root root 2.0K Oct 30 21:36 tmp_WBZNO
-rw-------. 1 root root 2.1K Oct 29 21:38 tmpXcXptG
-rw-------. 1 root root 2.0K Nov 5 21:40 tmpyqSR0U
-rw-------. 1 root root 2.1K Oct 28 21:42 tmpZjNjtu
我们可以修改/tmp目录的权限; 或者修改数据库的临时目录来解决这个问题:
1:在配置文件my.cnf中修改数据库的临时目录,然后需要重启MySQL数据库
tmpdir = /var/lib/mysql
2:修改/tmp目录权限
chmod 1777 /tmp
或
chmod 777 /tmp
那么MySQL使用tmpdir来做什么呢?tmpdir是MySQL存临时文件的目录的路径名。如果未设置变量tmpdir,MySQL将使用系统的默认值,通常为/tmp、/var/tmp或/usr/tmp。更多详细信息,可以参考官方文档Where MySQL Stores Temporary Files的详细介绍:
MySQL arranges that temporary files are removed if mysqld is terminated. On platforms that support it (such as Unix), this is done by unlinking the file after opening it. The disadvantage of this is that the name does not appear in directory listings and you do not see a big temporary file that fills up the file system in which the temporary file directory is located. (In such cases, lsof +L1 may be helpful in identifying large files associated with mysqld.)
When sorting (ORDER BY or GROUP BY), MySQL normally uses one or two temporary files. The maximum disk space required is determined by the following expression:
(length of what is sorted + sizeof(row pointer))* number of matched rows
* 2
The row pointer size is usually four bytes, but may grow in the future for really big tables.
For some SELECT queries, MySQL also creates temporary SQL tables. These are not hidden and have names of the form SQL_*.
DDL operations that rebuild the table and are not performed online using the ALGORITHM=INPLACE technique create a temporary copy of the original table in the same directory as the original table.
Online DDL operations may use temporary log files for recording concurrent DML, temporary sort files when creating an index, and temporary intermediate tables files when rebuilding the table. For more information, see Section 15.12.3, “Online DDL Space Requirements”.
InnoDB user-created temporary tables and on-disk internal temporary tables are created in a temporary tablespace file named ibtmp1 in the MySQL data directory. For more information, see Section 15.6.3.5, “Temporary Tablespaces”.
MySQL会以隐含方式创建所有的临时文件。这样,就能确保中止mysqld时会删除所有临时文件。使用隐含文件的缺点在于,在临时文件目录所在的位置中,看不到占用了文件系统的大临时文件。
进行排序时(ORDER BY或GROUP BY),MySQL通常会使用1个或多个临时文件。所需的最大磁盘空间由下述表达式决定:
(length of what is sorted + sizeof(row pointer))
* number of matched rows
* 2
“row pointer”(行指针)的大小通常是4字节,但在以后,对于大的表,该值可能会增加。
对于某些SELECT查询,MySQL还会创建临时SQL表。它们不是隐含表,并具有SQL_*形式的名称。
ALTER TABLE会在与原始表目录相同的目录下创建临时表。
如果内存临时表超出了限制,MySQL就会自动地把它转化为基于磁盘的MyISAM表,存储在指定的tmpdir目录下。
参考资料:
https://dev.mysql.com/doc/refman/8.0/en/temporary-files.html
Can't create/write to file '/tmp/MLjnvU95' (Errcode: 13 - Permission denied)的更多相关文章
- Mysql 错误 ERROR 1 (HY000) at line 1: Can't create/write to file '/home/kaizenly/cfg_dict.csv' (Errcode: 13 - Permission denied)
[1]问题描述 (1)执行SQL语句: use billing; select * from cfg_dict into outfile '/home/kaizenly/cfg_dict.csv' f ...
- 【docker】python: can't open file 'helloworld.py': [Errno 13] Permission denied
运行容器提示权限问题 docker run -v $PWD/myapp:/usr/src/myapp -w /usr/src/myapp python:3.5 python helloworld. ...
- Can't create/write to file '/tmp/#sql_887d_0.MYD' (Errcode: 17)
lsof |grep "#sql_887d_0.MYD" 如果没有被占用就可以删掉 . https://wordpress.org/support/topic/cant-creat ...
- ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode: 13)
mysql> desc tablename; ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode ...
- Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13)
最近的项目中由于临时存储空间太大了.索性把tmp目录删除了.结果访问出现 Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13) ...
- mysql执行SQL语句时报错:[Err] 3 - Error writing file '/tmp/MYP0G1B8' (Errcode: 28 - No space left on device)
问题描述: 今天一同事在mysql中执行SQL语句的时候,报了/tmp空间不足的问题,报错如下: [SQL] SELECT f.prov as 字段1, MAX( CASE f.flag_name W ...
- docker pull报错failed to register layer: Error processing tar file(exit status 1): open permission denied
近来在一个云主机上操作docker pull,报错如下: failed to register layer: Error processing ): open /etc/init.d/hwclock. ...
- 报错:/usr/sbin/mysqld: Can't find file: './performance_schema/events_waits_summary_by_account_by_event_name.frm' (errno: 13 - Permission denied)
报错背景: Linux环境下安装MySQL数据库. 安装完成,数据库初始化,启动数据库时报错. 报错现象: -- :: [ERROR] Native table 'performance_schema ...
- Jupyter运行时出现下面的错误:Unexpected error while saving file: arma/Untitled.ipynb [Errno 13] Permission denied:
运行环境:Ubuntu16.04+Python2.7执行如下代码修改Jupyter的一部分文件的权限(执行完之后重新启动即可): sudo chmod ~/.local/share/jupyter/ ...
随机推荐
- [Swift]LeetCode853. 车队 | Car Fleet
N cars are going to the same destination along a one lane road. The destination is target miles awa ...
- [Swift]LeetCode855. 考场就座 | Exam Room
In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. When a student enter ...
- 学习HTML5 canvas遇到的问题
学习HTML5 canvas遇到的问题 1. 非零环绕原则(nonzZero rule) 非零环绕原则是canvas在进行填充的时候是否要进行填充的判断依据. 在判断填充的区域拉一条线出来,拉到图形的 ...
- 低延时的P2P HLS直播技术实践
本文根据4月21日OSC源创会·武汉站的现场分享为蓝本,重新整理.以下是演讲内容: 近几年,随着直播.短视频等视频领域对带宽要求的提升以及CDN行业竞争的加剧,很多CDN公司开始往P2P-CDN方向发 ...
- DDD实战进阶第一波(十五):开发一般业务的大健康行业直销系统(总结篇)
前面我们花了14篇的文章来给大家介绍经典DDD的概念.架构和实践.这篇文章我们来做一个完整的总结,另外生成一个Api接口文档. 一.DDD解决传统的开发的几大问题: 没有描述需求的设计模型:而是直接通 ...
- 【斐波那契数列】java探究
题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0). n<=39 解析 (1)递归方式 对于公式f(n) = f(n-1) + f(n ...
- C#2.0 委托
委托 委托是一个非常不错的设计,允许我们把方法做为参数传递,实现了开放閉放原则.在方法中我们只要有一个委托占位,调用者就可以传入符合签名的方法来做不同的操作,这也面向对象开发中多态的魅力. 但是在C# ...
- RabbitMQ消息队列(五)-安装amqp扩展并订阅/发布Demo(.Net Core版)
publish发布消息 新建一个Asp.Net Core控制台项目:PublishDemo 安装Nuget包 Install-Package RabbitMQ.Client 添加命名空间引用 usin ...
- 离线批量数据通道Tunnel的最佳实践及常见问题
基本介绍及应用场景 Tunnel是MaxCompute提供的离线批量数据通道服务,主要提供大批量离线数据上传和下载,仅提供每次批量大于等于64MB数据的场景,小批量流式数据场景请使用DataHub实时 ...
- J2EE规范总结
概述 J2ee是我们步入java学习的一个開始.它将开启这趟奇幻之旅,Java是一种简单的,跨平台的,面向对象的,分布式的.解释的.健壮的安全的.结构的中立的,可移植的.性能非常优异的多线程的,动态的 ...