溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么解決MYSQL中的Errcode: 17 - File exists問(wèn)題

發(fā)布時(shí)間:2021-11-18 15:57:18 來(lái)源:億速云 閱讀:1185 作者:iii 欄目:MySQL數(shù)據(jù)庫(kù)

本篇內(nèi)容主要講解“怎么解決MYSQL中的Errcode: 17 - File exists問(wèn)題”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“怎么解決MYSQL中的Errcode: 17 - File exists問(wèn)題”吧。

現(xiàn)象:

執(zhí)行show fields from a時(shí)報(bào)下面的錯(cuò)誤

Error: Can't create/write to file '/tmp/#sql_419_0.MYI' (Errcode: 17 - File exists): SHOW FULL FIELDS FROM `a`

解決方法:

在/tmp下,把相關(guān)的#sql文件移除即可

重現(xiàn):

[root@10-19-187-240 tmp]# ll | grep sql
-rw-r--r-- 1 root  root    531453 1月  10 19:55 a.sql
lrwxrwxrwx 1 root  root        25 1月   9 18:14 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-rw---- 1 mysql mysql    98304 1月  21 21:23 test.ibd
-rw-rw---- 1 mysql mysql        7 1月  22 11:15 t_myisam.MYD
-rw-rw---- 1 mysql mysql     1024 1月  22 11:15 t_myisam.MYI


show fileds 開(kāi)始執(zhí)行時(shí):
[root@10-19-187-240 tmp]# ll | grep sql
-rw-r--r-- 1 root  root    531453 1月  10 19:55 a.sql
lrwxrwxrwx 1 root  root        25 1月   9 18:14 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-rw---- 1 mysql mysql        0 2月  14 14:20 #sql_5ec_0.MYD
-rw-rw---- 1 mysql mysql     1024 2月  14 14:20 #sql_5ec_0.MYI
-rw-rw---- 1 mysql mysql    98304 1月  21 21:23 test.ibd
-rw-rw---- 1 mysql mysql        7 1月  22 11:15 t_myisam.MYD
-rw-rw---- 1 mysql mysql     1024 1月  22 11:15 t_myisam.MYI
[root@10-19-187-240 tmp]#
[root@10-19-187-240 tmp]#
[root@10-19-187-240 tmp]# cp "#sql_5ec_0.MYD" ~/
[root@10-19-187-240 tmp]# cp "#sql_5ec_0.MYI" ~/

show filelds 執(zhí)行完成 后:
[root@10-19-187-240 tmp]# ll | grep sql
-rw-r--r-- 1 root  root    531453 1月  10 19:55 a.sql
lrwxrwxrwx 1 root  root        25 1月   9 18:14 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-rw---- 1 mysql mysql    98304 1月  21 21:23 test.ibd
-rw-rw---- 1 mysql mysql        7 1月  22 11:15 t_myisam.MYD
-rw-rw---- 1 mysql mysql     1024 1月  22 11:15 t_myisam.MYI
[root@10-19-187-240 tmp]#
[root@10-19-187-240 tmp]#

把原來(lái)的文件 copy回來(lái)
[root@10-19-187-240 tmp]# cp ~/"#sql_5ec_0.MYD" ./
[root@10-19-187-240 tmp]# cp ~/"#sql_5ec_0.MYI" ./
[root@10-19-187-240 tmp]# ll
總用量 20532
-rw-r--r-- 1 root  root    531453 1月  10 19:55 a.sql
drwxr-xr-x 6 root  root      4096 1月  12 14:50 data
-rw-r--r-- 1 root  root  20376794 1月  14 21:34 data.zip
lrwxrwxrwx 1 root  root        25 1月   9 18:14 mysql.sock -> /var/lib/mysql/mysql.sock
-rw-r----- 1 root  root         0 2月  14 14:21 #sql_5ec_0.MYD
-rw-r----- 1 root  root      1024 2月  14 14:21 #sql_5ec_0.MYI
-rw-rw---- 1 mysql mysql    98304 1月  21 21:23 test.ibd
-rw-rw---- 1 mysql mysql        7 1月  22 11:15 t_myisam.MYD
-rw-rw---- 1 mysql mysql     1024 1月  22 11:15 t_myisam.MYI

再次執(zhí)行show fields

怎么解決MYSQL中的Errcode: 17 - File exists問(wèn)題

就可以重現(xiàn)上面的錯(cuò)誤

調(diào)用過(guò)程:

#0  fill_schema_table_by_open (thd=0x2293ee0,
    is_show_fields_or_keys=true, table=0x7fbed405c310,
    schema_table=0x1531980, orig_db_name=0x7fbf00dfea20,
    orig_table_name=0x7fbf00dfea10,
    open_tables_state_backup=0x7fbf00dfe8b0,
    can_deadlock=false)
    at /data/mysql-5.6.35/sql/sql_show.cc:3470
#1  0x000000000084107e in get_all_tables (thd=0x2293ee0,
    tables=0x7fbed4006090, cond=0x0)
    at /data/mysql-5.6.35/sql/sql_show.cc:4131
#2  0x000000000084f655 in do_fill_table (thd=0x2293ee0,
    table_list=0x7fbed4006090, join_table=0x7fbed4065358)
    at /data/mysql-5.6.35/sql/sql_show.cc:7433
#3  0x000000000084fa2c in get_schema_tables_result (
    join=0x7fbed405aae0,
    executed_place=PROCESSED_BY_JOIN_EXEC)
    at /data/mysql-5.6.35/sql/sql_show.cc:7534
#4  0x00000000008238c7 in JOIN::prepare_result (
    this=0x7fbed405aae0, columns_list=0x7fbf00dfeda0)
    at /data/mysql-5.6.35/sql/sql_select.cc:822
#5  0x00000000007c10ef in JOIN::exec (this=0x7fbed405aae0)
    at /data/mysql-5.6.35/sql/sql_executor.cc:116
#6  0x0000000000824408 in mysql_execute_select (
    thd=0x2293ee0, select_lex=0x2296478, free_join=true)
    at /data/mysql-5.6.35/sql/sql_select.cc:1101
#7  0x000000000082471f in mysql_select (thd=0x2293ee0,
    tables=0x7fbed4006090, wild_num=0, fields=...,
    conds=0x0, order=0x2296640, group=0x2296578,
    having=0x0, select_options=2684619520,
    result=0x7fbed405aab8, unit=0x2295e30,
    select_lex=0x2296478)
    at /data/mysql-5.6.35/sql/sql_select.cc:1222
#8  0x000000000082273b in handle_select (thd=0x2293ee0,
    result=0x7fbed405aab8, setup_tables_done_option=0)
    at /data/mysql-5.6.35/sql/sql_select.cc:110
#9  0x00000000007fb93e in execute_sqlcom_select (
    thd=0x2293ee0, all_tables=0x7fbed4006090)
    at /data/mysql-5.6.35/sql/sql_parse.cc:5181
#10 0x00000000007f4081 in mysql_execute_command (
    thd=0x2293ee0)
    at /data/mysql-5.6.35/sql/sql_parse.cc:2689
---Type <return> to continue, or q <return> to quit---
#11 0x00000000007fe4bc in mysql_parse (thd=0x2293ee0,
    rawbuf=0x7fbed4005030 "show fields from a", length=18,
    parser_state=0x7fbf00e00670)
    at /data/mysql-5.6.35/sql/sql_parse.cc:6433
#12 0x00000000007f0f7d in dispatch_command (
    command=COM_QUERY, thd=0x2293ee0,
    packet=0x2368eb1 "show fields from a",
    packet_length=18)
    at /data/mysql-5.6.35/sql/sql_parse.cc:1372
#13 0x00000000007eff56 in do_command (thd=0x2293ee0)
    at /data/mysql-5.6.35/sql/sql_parse.cc:1039
#14 0x00000000007b5f35 in do_handle_one_connection (
    thd_arg=0x2293ee0)
    at /data/mysql-5.6.35/sql/sql_connect.cc:982
#15 0x00000000007b5cca in handle_one_connection (
    arg=0x2293ee0)
    at /data/mysql-5.6.35/sql/sql_connect.cc:899
#16 0x0000000000b33da0 in pfs_spawn_thread (arg=0x21e64c0)
    at /data/mysql-5.6.35/storage/perfschema/pfs.cc:1860
#17 0x00007fbf2c56faa1 in start_thread ()
   from /lib64/libpthread.so.0
#18 0x00007fbf2b2d8aad in clone () from /lib64/libc.so.6

經(jīng)過(guò)一步步的查看,發(fā)現(xiàn)是在
create_tmp_table (thd=0x2293ee0, param=0x7fbed405a050,
fields=..., group=0x0, distinct=false,
save_sum_fields=false, select_options=2147752704,
rows_limit=18446744073709551615,
table_alias=0x7fbed4006088 "COLUMNS")
at /data/mysql-5.6.35/sql/sql_tmp_table.cc:455
生成的臨時(shí)表。
實(shí)際上是查看了information_schema中的表

到此,相信大家對(duì)“怎么解決MYSQL中的Errcode: 17 - File exists問(wèn)題”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI