【问题标题】:DROP DATABASE crash mysql serverDROP DATABASE 崩溃 mysql 服务器
【发布时间】:2014-06-02 21:05:32
【问题描述】:

当我想删除我的数据库时,我遇到了一个小问题。

当我执行时:

DROP DATABASE `mydb`;

MySQL 返回:

Error Code: 2013. Lost connection to MySQL server during query

(从 phpmyadmin 执行,我已断开连接并重定向到登录名/密码)

问题可能是一个幻表。

如果我执行:

CHECK TABLE `mydb`.`mytable`

我有:

Error Code: 1146. Table 'mydb.mytable' doesn't exist

但是如果我执行:

CREATE TABLE IF NOT EXISTS `mydb`.`mytable` ...

我有:

Error Code: 1050. Table '`mydb`.`mytable`' already exists

"SELECT *" 表示它不存在。

我在执行 DROP DATABASE 时尝试过 innodb_force_recovery 6:

InnoDB: Load table 'mydb/mytable' failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again.140417 11:09:55 InnoDB: Assertion failure in thread 2797190000 in file row0mysql.c line 3683
InnoDB: Failing assertion: table
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/...-recovery.html
InnoDB: about forcing recovery.
09:09:55 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346075 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0xffffffffb9523670
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = ffffffffa6b9b32c thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x33)[0xb7329743]
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0xb71ca984]
[0xb6e7f400]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(abort+0x182)[0xb6b8bd72]
/usr/sbin/mysqld(+0x4e1e3b)[0xb737fe3b]
/usr/sbin/mysqld(+0x4c8d6a)[0xb7366d6a]
/usr/sbin/mysqld(+0x32ca05)[0xb71caa05]
/usr/sbin/mysqld(_Z24plugin_foreach_with_maskP3THDPFcS0_P13st_plugin_intPvEijS3_+0x1d1)[0xb70ac121]
/usr/sbin/mysqld(_Z16ha_drop_databasePc+0x3f)[0xb71cbb9f]
/usr/sbin/mysqld(_Z11mysql_rm_dbP3THDPcbb+0xc13)[0xb707b073]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x4477)[0xb709fff7]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x254)[0xb70a2f54]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x2000)[0xb70a5910]
/usr/sbin/mysqld(_Z10do_commandP3THD+0xce)[0xb70a63de]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0x123)[0xb7155983]
/usr/sbin/mysqld(handle_one_connection+0x50)[0xb7155ab0]
/lib/i386-linux-gnu/i686/cmov/libpthread.so.0(+0x5c39)[0xb6e5dc39]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(clone+0x5e)[0xb6c34d4e]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (ffffffffb9599500): DROP DATABASE `mydb`
Connection ID (thread ID): 2
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

想法?

【问题讨论】:

  • 用户对mydb有权限吗?
  • 尝试停止 mysql 服务器并使用此命令重新启动它。 mysqld_safe 启动
  • 我使用 root 所以是的,我有权限
  • 当我使用 mysqld_safe start 时,我的系统日志与我发布的系统日志中的关系相同
  • 相关的 .frm 和/或 .ibd 文件是否存在于文件系统的数据目录中(可能是 /var/lib/mysql)?

标签: mysql


【解决方案1】:

请检查max_allowed_packetmy.ini 的值对于Windows 和my.cnf 对于Linux 并增加值然后重新启动服务才能生效。这应该可以解决问题。

【讨论】:

  • max_allowed_packet 与 TCP/IP 数据包有关,在 OP 问题中,肯定数据包不会很大。
  • max_allowed_pa​​cket 用于确保客户端在尝试执行需要大量内存的命令时不会丢失连接,即使参数不存在,max_allowed_pa​​cket 的值也太小在ini或cnf文件上。但是如果第一个解决方案没有解决问题,我们可以从 datadir 中的 err 文件中获取更多信息。
  • dev.mysql.com/doc/refman/5.0/en/… : 一个数据包或任何生成/中间字符串的最大大小。 DROP DATABASE 不应生成任何大数据包或中间字符串...
  • dev.mysql.com/doc/refman/5.5/en/packet-too-large.html 用户尝试通过客户端工具或 MySQLD 执行 SQL 命令时使用的最大允许数据包
  • 我已经将值 16M 更改为 128M 并且总是同样的问题
【解决方案2】:

可能是数据文件或 .frm 文件消失了。

【讨论】:

    【解决方案3】:

    几天来,我一直在努力寻找解决同一问题的方法。之后,我通过禁用 InnoDB 解决了这个问题。实际上,禁用 InnoDB 后,我可以再次将表创建为 MyISAM。然后我启用了 InnoDB。在 MySql (MariaDB) 日志中,它仍然抱怨无法加载表。不过,我可以使用新的 MyISAM 表来解决问题。

    顺便说一句,我删除并重新创建了数据库,但它并没有解决问题。删除数据库时,出现“连接丢失”错误。禁用 InnoDB 后,我成功删除了数据库。

    要禁用 InnoDB,请在 my.cnf 中写入以下行并重新启动 mysql 服务。

    [mysqld]
    skip-innodb
    default-storage-engine = myisam
    

    将丢失的表重新创建为 MyISAM 后,我启用了 InnoDB。

    【讨论】:

      猜你喜欢
      • 2014-12-20
      • 2010-10-01
      • 1970-01-01
      • 2011-03-29
      • 2013-12-03
      • 1970-01-01
      • 2016-06-12
      • 2017-07-29
      • 1970-01-01
      相关资源
      最近更新 更多