MySQL/写入文件错误 (Errcode 28)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7415710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:04:14  来源:igfitidea点击:

MySQL/Writing file error (Errcode 28)

mysqllogging

提问by Zabs

I have the following error with one of our web applications -

我的一个 Web 应用程序出现以下错误 -

Query3 failed: Error writing file '/tmp/MY1fnqpm' (Errcode: 28) ... INSERT MailList... (removed the rest of the query for security reasons)

Any ideas - is this some hard disk space issue on my server?

任何想法 - 这是我服务器上的硬盘空间问题吗?

回答by Arnaud Le Blanc

Use the perrorcommand:

使用perror命令

$ perror 28
OS error code  28:  No space left on device

Unless error codes are different on your system, your file system is full.

除非您的系统上的错误代码不同,否则您的文件系统已满。

回答by XSeryoga

We have experienced similar issue, and the problem was MySQL used /tmp directory for its needs (it's default configuration). And /tmp was located on its own partition, that had too few space for big MySQL requests.

我们遇到过类似的问题,问题是 MySQL 使用 /tmp 目录来满足其需要(这是默认配置)。并且 /tmp 位于它自己的分区上,该分区对于大型 MySQL 请求来说空间太少。

For more details take a look for this answer: https://stackoverflow.com/a/3716778/994302

有关更多详细信息,请查看此答案:https: //stackoverflow.com/a/3716778/994302

回答by Turshija

I had same problem but disk space was okay (only 40% full). Problem were inodes, I had too many small files and my inodes were full.

我有同样的问题,但磁盘空间没问题(只有 40% 已满)。问题是 inode,我有太多的小文件,我的 inode 已满。

You can check inode status with df -i

您可以使用 df -i 检查 inode 状态

回答by SlayerX

The error means that you dont have enough space to create temp files needed by MySQL.

该错误意味着您没有足够的空间来创建 MySQL 所需的临时文件。

The first thing you can try is to expand the size of your /tmp/partition. If you are under LVM, check the lvextendcommand.

您可以尝试的第一件事是扩大/tmp/分区的大小。如果您在 LVM 下,请检查lvextend命令。

If you are not able to increase the size of your partition /tmp/you can work in the MySQL configuration, edit the my.cnf(typically on /etc/mysql/my.cnf) file and look for this line:

如果您无法增加分区的大小,您/tmp/可以在 MySQL 配置中工作,编辑my.cnf(通常在/etc/mysql/my.cnf)文件并查找以下行:

tmpdir = /tmp/

tmpdir = /tmp/

Change it for whatever you want (example /var/tmp/). Just be sure to have space and assign write permission for the mysql user in the new directory.

随心所欲地更改它(示例/var/tmp/)。只要确保有空间并为新目录中的mysql用户分配写权限即可。

Hope this helps!

希望这可以帮助!

回答by Alex

Run the following code:

运行以下代码:

du -sh /var/log/mysql

du -sh /var/log/mysql

Perhaps mysql binary logs filled the memory, If so, follow the removal of old logs and restart the server. Also add in my.cnf:

可能是mysql二进制日志占满了内存,如果是这样,请按照清除旧日志并重新启动服务器。还要在 my.cnf 中添加:

expire_logs_days = 3

expire_logs_days = 3

回答by Samuel Frost

I had this same error and the problem was simply not enough space on my virtual machine. I deleted some unnecessary files and it started working again.

我有同样的错误,问题只是我的虚拟机上没有足够的空间。我删除了一些不必要的文件,然后它又开始工作了。

my memory/disk space allocation looked something like this

我的内存/磁盘空间分配看起来像这样

df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   37G   37G  127M 100% /
...

回答by Wyatt

You can also try using this line if the other doesn't work:

如果另一个不起作用,您也可以尝试使用此行:

du -sh /var/lib/mysql/database_Name

du -sh /var/lib/mysql/database_Name

You may also want to check with your host and see how big they allow your databases to be.

您可能还想与您的主机核对一下,看看它们允许您的数据库有多大。

回答by Sandro Rosa

For xampp users: on my experience, the problem was caused by a file, named '0' and located in the 'mysql' folder. The size was tooooo huge (mine exploded to about 256 Gb). Its removal fixed the problem.

对于 xampp 用户:根据我的经验,问题是由名为“0”并位于“mysql”文件夹中的文件引起的。大小太大了(我的爆炸到大约 256 Gb)。它的删除解决了这个问题。

回答by Daniel Bernardez

This error occurs when you don't have enough space in the partition. Usually MYSQL uses /tmp on linux servers. This may happen with some queries because the lookup was either returning a lot of data, or possibly even just sifting through a lot of data creating big temp files.

当分区中没有足够空间时会发生此错误。通常 MYSQL 在 linux 服务器上使用 /tmp 。某些查询可能会发生这种情况,因为查找要么返回大量数据,要么甚至可能只是筛选大量数据以创建大型临时文件。

Edit your /etc/mysql/my.cnf

编辑你的 /etc/mysql/my.cnf

tmpdir = /your/new/dir

tmpdir = /你的/新的/目录

e.g

例如

tmpdir = /var/tmp

tmpdir = /var/tmp

Should be allocated with more space than /tmp that is usually in it's own partition.

应该分配比 /tmp 多的空间,通常在它自己的分区中。

回答by Медведев Александр

Today. I have same problem... my solution:

今天。我有同样的问题......我的解决方案:

1) check inode: df -iI saw:

1)检查inode:df -i我看到:

root@vm22433:/etc/mysql# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 124696 304 124392 1% /dev
tmpfs 127514 452 127062 1% /run
/dev/vda1 1969920 1969920 0 100% /
tmpfs 127514 1 127513 1% /dev/shm
tmpfs 127514 3 127511 1% /run/lock
tmpfs 127514 15 127499 1% /sys/fs/cgroup
tmpfs 127514 12 127502 1% /run/user/1002

2) I began to look what folders use the maximum number of inods:

2)我开始查看哪些文件夹使用的inod数最大:

 for i in /*; do echo $i; find $i |wc -l; done

soon I found in /home/tomnolane/tmp folder, which contained a huge number of files.

很快我在 /home/tomnolane/tmp 文件夹中找到了,其中包含大量文件。

3) I removed /home/tomnolane/tmp folder PROFIT.

3) 我删除了 /home/tomnolane/tmp 文件夹 PROFIT。

4) checked:

4)检查:

Filesystem      Inodes  IUsed   IFree IUse% Mounted on
udev            124696    304  124392    1% /dev
tmpfs           127514    454  127060    1% /run
/dev/vda1      1969920 450857 1519063   23% /
tmpfs           127514      1  127513    1% /dev/shm
tmpfs           127514      3  127511    1% /run/lock
tmpfs           127514     15  127499    1% /sys/fs/cgroup
tmpfs           127514     12  127502    1% /run/user/1002

it's ok.

没关系。

5) restart mysql service- it's ok!!!!

5) restart mysql service- 没关系!!!!