MySQL Error Query database. Causejava.sql.SQLException: Incorrect key file for table ‘/tmp/#sql_181c,

來源:互聯網
上載者:User

MySQL Error Query database. Causejava.sql.SQLException: Incorrect key file for table ‘/tmp/#sql_181c,

 

 

 

1,開發人員給我,後台報錯如下:

Error Query database. Causejava.sql.SQLException: Incorrect key file for table ‘/tmp/#sql_181c_0.MYI’; tryto repair it;

 

分析,這種,大多數情況是tmp暫存資料表空間不足,所以執行比較複雜的sql或者執行大表關聯的時候,需要暫存資料表資源較多,如果暫存資料表資源少的話,就會保錯。

 

2,看看tmp_table_size值

 

mysql> show variables like '%tmp%';
+----------------------------+------------+
| Variable_name              | Value      |
+----------------------------+------------+
| default_tmp_storage_engine | InnoDB     |
| max_tmp_tables             | 32         |
| slave_load_tmpdir          | /tmp       |
| tmp_table_size             | 524288000 |
| tmpdir                     | /tmp       |
+----------------------------+------------+
5 rows in set (0.00 sec)

mysql> 

mysql> select 524288000/1024/1024/1024;

+--------------------------+

| 524288000/1024/1024/1024 |

+--------------------------+

|          0.488281250000 |

+--------------------------+

1 row in set (0.00 sec)

 ----------------------------------------------------------------------------------------------------------------
<著作權,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!>
原部落格地址:   http://blog.csdn.net/mchdba/article/details/45895681
原作者:黃杉 (mchdba)
----------------------------------------------------------------------------------------------------------------

 

mysql>


查下 tmp_table_size的值,發現這個太小了才500M都不到,加大4倍試試

 

3,修改tmp_table_size值

mysql> set global tmp_table_size =2462177282;

Query OK, 0 rows affected (0.00 sec)

 

mysql>

 

 

改完了,讓開發人員重新串連下資料庫,貌似還是原來的錯誤,再加大一倍試試

 

mysql> set global tmp_table_size =5122177282;

Query OK, 0 rows affected (0.00 sec)

 

mysql>

 

然後讓開發人員再登入mysql庫,查詢試試,OK了。

 

4,總結

這種情況,從營運dba角度,加大tmp_table_size的值,從開發dba角度,最佳化sql不要寫那麼效率低下的sql語句造成臨時資料過大。

 

 

參考文章地址:

http://www.mysqlperformancetuning.com/a-fix-for-incorrect-key-file-for-table-mysql

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.