gpt4 book ai didi

Mysql 服务器在十次查询后就消失了

转载 作者:行者123 更新时间:2023-11-29 23:07:31 26 4
gpt4 key购买 nike

我有一个由 MySQL Workbench 生成的 sql 脚本,它创建我的数据库/表等。它的形式为

-- MySQL Script generated by MySQL Workbench
-- 01/29/15 11:35:28
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema dbname
-- -----------------------------------------------------
-- Some description

-- -----------------------------------------------------
-- Schema dbname
--
-- Some description
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `dbname` ;

-- -----------------------------------------------------
-- Table `dbname`.`countries`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `dbname`.`countries` (
`name` VARCHAR(40) NOT NULL,
PRIMARY KEY (`name`))
ENGINE = InnoDB;
SHOW WARNINGS;

...

依此类推,创建多个表,然后插入一些值。

但是,如果我尝试运行它,可以通过

mysql -u root --password=xxx < schema.sql

source /path/to/schema.sql;

在 mysql shell 中,我得到以下内容

Query OK, 0 rows affected (0.00 sec)

...

Query OK, 1 row affected (0.00 sec)

Database changed
Query OK, 0 rows affected (0.01 sec)

Empty set (0.00 sec)

...

Query OK, 0 rows affected (0.01 sec)

Empty set (0.00 sec)

ERROR 2013 (HY000): Lost connection to MySQL server during query
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR:
Can't connect to the server

No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR:
Can't connect to the server

...

有10次查询成功,其余全部失败。再次运行给出相同的结果(但有警告,因为一些表现在已经存在)。

如何停止此错误 2013 并创建我的所有表?

更新

我检查了日志文件,在/var/log/mysql/error.log中发现了一系列这种形式的日志

150130 11:55:32 [ERROR] Cannot find or open table playwhoo/joinRequests from
the internal data dictionary of InnoDB though the .frm file for the
table exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files
of InnoDB tables, or you have moved .frm files to another database?
or, the table contains indexes that this version of the engine
doesn't support.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.

但是,我在网上能找到的唯一帮助是由于手动移动文件而发生此错误(不是我所做的,尽管我在出现此问题之前进行了备份)。

最佳答案

拆开我的 schema.sql 看看它当时失败的原因后,终于解决了这个问题。

事实证明我没有说出任何限制。也就是说,它们看起来都是这样的:

CONSTRAINT ``
FOREIGN KEY (`user`)
REFERENCES `dbname`.`users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION

MySQL 对此表示反对,并生成了 error 121 。当在MySQL命令行中一一输入命令时,这一点就很明显了。然而,当批量完成时,整个事情就崩溃了,并给出了神秘的MySQL服务器已经消失

我仍然有兴趣知道(在下面的评论中)是否有正确的错误传播缺乏的正当理由。为什么它不说有错误 121 而不是连接失败(就像它所做的那样)?

关于Mysql 服务器在十次查询后就消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28232876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com