简体   繁体   中英

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. 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:

It says

Import has been successfully finished, 1 queries executed. (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; 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

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; 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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