简体   繁体   English

导入schema.sql时出错

[英]Error when importing schema.sql

I'm new to sql, currently I am using phpMyAdmin via XAMP, I think that uses mysql so correct me if I'm wrong by saying that. 我是sql的新手,目前我通过XAMP使用phpMyAdmin,我认为它使用mysql,因此如果我说错了,请更正我。 Anywhos, I'm trying to import a schema.sql data file into my database I created called "test" but I got an error upon importing it: 无论如何,我正在尝试将schema.sql数据文件导入到我创建的数据库中,该文件称为“测试”,但导入时出现错误:

It says 它说

Import has been successfully finished, 1 queries executed. 导入已成功完成,已执行1个查询。 (schema.sql) (schema.sql)

But then it also gives me an error message: 但这又给了我一条错误消息:

CREATE TABLE `population` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `location` varchar(150) NOT NULL,
 `slug` varchar(150) NOT NULL,
 `population` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL said: Documentation

1075 - Incorrect table definition; 1075-错误的表格定义; there can be only one auto column and it must be defined as a key 只能有一个自动列,并且必须将其定义为键

and : 和:

Notice in .\\import.php#704 Undefined variable: import_text Backtrace 请注意。\\ import.php#704中的未定义变量:import_text Backtrace

I'm not sure what the issue is. 我不确定是什么问题。 The database I created is completely and has nothing in it. 我创建的数据库完全没有任何内容。

Column id is the auto-column in question; id是有问题的自动列; auto-columns need to be defined as a key, for example as a unique key or a primary key. 自动列需要定义为键,例如,唯一键或主键。 In your case, a primary key is a good idea because - well, it's your id-column. 在您的情况下,主键是一个好主意,因为-嗯,这是您的id列。

CREATE TABLE `population` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `location` varchar(150) NOT NULL,
 `slug` varchar(150) NOT NULL,
 `population` int(10) unsigned NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM