MySQL 的密钥文件不正确
我遇到了 InnoDB 表的问题(表最初是 MyISAM,但不久前将其转换为 InndoB)表;我正在尝试运行此查询:
SELECT
posts.id,
posts.post_title
FROM
rss_posts AS posts
INNER JOIN rss_feeds AS feeds ON posts.blog_id=feeds.id
WHERE
feeds.blog_language=1
ORDER BY
posts.post_date_db DESC
LIMIT
10;
我收到此错误:
Query : SELECT posts.id,posts.post_title FROM rss_posts AS posts INNER JOIN vw_rss_feeds AS feeds ON posts.blog_id=feeds.id WHER...
Error Code : 126
Incorrect key file for table '/tmp/#sql_7375_0.MYI'; try to repair it
我无法对涉及的表运行修复;但是我已经对两个表和表进行了检查。他们看起来很好。我还对两个表和表进行了优化。还通过执行以下操作重建表。
INSERT INTO new_table SELECT * FROM old_table;
然后我将新表重命名为旧表名称......但我仍然遇到这个问题。
尝试&找出导致它的表我删除了引用“rss_feeds”表的查询中的代码....所以现在查询看起来像这样..
SELECT
posts.id,
posts.post_title
FROM
rss_posts AS posts
ORDER BY
posts.post_date_db DESC
LIMIT
10;
有效。
所以问题出在 rss_feeds 表上。
所以我想我应该将表转换回 MyISAM & 。进行维修&然后转换回InnoDB......这暂时有效,它恢复正常......然后它再次损坏......再次修复它,再次损坏......现在修复似乎没有根本不工作。
现在,我知道了,我知道了......我已经在Google上搜索过这个问题......我注意到大多数时候问题是MySQL临时目录中没有足够的空间。 ...但我已经让主机将临时目录更改为具有更多空间和空间的目录。问题仍然存在。
我认为主机应该受到责备&它仍然是临时目录的问题;为什么?因为在我让它再次工作后,我开始再次将数据添加到 rss_posts 表中。因此 JOIN 会变得更大并且更小。 MySQL 将再次耗尽空间......你觉得怎么样?
I'm having a problem with a InnoDB (table was initally MyISAM, but converted it to InndoB awhile ago) table; I am trying to run this query:
SELECT
posts.id,
posts.post_title
FROM
rss_posts AS posts
INNER JOIN rss_feeds AS feeds ON posts.blog_id=feeds.id
WHERE
feeds.blog_language=1
ORDER BY
posts.post_date_db DESC
LIMIT
10;
I get this error:
Query : SELECT posts.id,posts.post_title FROM rss_posts AS posts INNER JOIN vw_rss_feeds AS feeds ON posts.blog_id=feeds.id WHER...
Error Code : 126
Incorrect key file for table '/tmp/#sql_7375_0.MYI'; try to repair it
I cannot run a repair on the tables involved; however I have ran a CHECK on both tables & they appear fine. I have also done an OPTIMIZE on both tables & ALSO rebuilt the tables by doing the below..
INSERT INTO new_table SELECT * FROM old_table;
I then renamed the new table to the old table name..... but I am STILL having that problem.
To try & figure out what table was causing it I removed the code in the query referencing the "rss_feeds" table.... so now the query looks like this..
SELECT
posts.id,
posts.post_title
FROM
rss_posts AS posts
ORDER BY
posts.post_date_db DESC
LIMIT
10;
That worked.
So the problem is something with the rss_feeds table.
So then I figured I would convert the table back to MyISAM & run a repair & then convert back to InnoDB..... this worked temporarily, it was back to normal.... then it broke again..... repaired it again, broke again.... now the repair doesn't seem to work at all.
Now, I know, I know...... I have searched for this problem on Google already...... I noticed that the MAJORITY of the time the problem is there us not enough space in the MySQL temp directory.... but I already got the host to change the temp dir to something with a LOT more space & the problem still remains.
I'm thinking the HOST is to blame & it STILL is a problem with the temp dir; why? Because after I got it working again I started adding data to the rss_posts table again & hence the JOIN would get LARGER & MySQL would again run out of space.... what do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里发生的事情是 MySQL 通过从两个表的连接构建一个临时表来执行 ORDER BY。临时表太大,内存无法容纳,因此 MySQL 创建一个临时文件。
有一些事情会阻止它正常工作。原始磁盘空间就是其中之一。 ulimit 是另一个。如果这是托管的,他们可能对您的磁盘使用有配额(除了 ulimit 之外)。
我建议在您的查询中添加一个限制子句。当前,您将整个 rss_posts 和 rss_feeds 加载到临时表中进行排序。如果您只想要最近的 10 个数据,那么这比您真正需要的数据要多得多。
What's going on here is MySQL is doing the ORDER BY by building a temporary table from the join of the two tables. The temporary table is too large to fit into memory so MySQL creates a temporary file.
There are a few thing that would prevent this from working correctly. Raw disk space is one. ulimit is another. If this is being hosted, they may have a quota on your disk usage (in addition to ulimit).
I would suggest adding a limiting clause to your query. Currently you load the entire of both the rss_posts and rss_feeds into the temporary table for sorting. If you only want the most recent 10 that's a lot more data than you really need.
看来临时表的磁盘配额太小了。
顺便说一句:不需要在 InnoDB 表上运行 REPAIR,因为所有维护都是由存储引擎本身完成的。他们也没有可损坏的密钥文件。
It sure looks like the disk quota you have for temporary tables is too small.
BTW: There's no need to run REPAIR on InnoDB tables, since all the maintenance is done by the storage engine itself. They also do not have a key file to be corrupted.
请注意,存在问题的 .MYI 文件是针对临时表的。当您运行涉及连接的查询时,MySql 需要使用临时空间在内部合并数据。您的 tmp 目录中的空间很可能已用完。
尝试增加分配给 tmpdir 的空间量或编辑 my.cnf 文件以使 tmpdir 指向具有足够空间的位置(不要忘记授予它权限)。
Notice that the .MYI file its having a problem with is for a temp table. When you're running queries involving joins, MySql needs to use temp space to merge the data internally. You are most likely running out of space in your tmp directory.
Try increasing the amount of space allocated to tmpdir or edit the my.cnf file to have tmpdir point to a place with enough space (don't forget to give it permissions).