phpMyAdmin导出的数据库备份导到MySQL workbench失败

MySql 码拜 8年前 (2016-02-13) 913次浏览
phpMyAdmin4.4.1导出的数据库脚本

DROP TABLE IF EXISTS `xx_ad`;
CREATE TABLE IF NOT EXISTS `xx_ad` (
  `id` bigint(20) NOT NULL auto_increment,
  `create_date` datetime NOT NULL,
  `modify_date` datetime NOT NULL,
  `orders` int(11) default NULL,
  `begin_date` datetime default NULL,
  `content` longtext,
  `end_date` datetime default NULL,
  `path` varchar(255) default NULL,
  `title` varchar(255) NOT NULL,
  `type` int(11) NOT NULL,
  `url` varchar(255) default NULL,
  `ad_position` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

MySQL workbench执行时,报错“Error Code: 1075. Incorrect table definition; there can be only one auto column and it must be defined as a key
phpMyAdmin导出的数据库备份导到MySQL workbench失败

解决方案

10

少了主键定义。

30

引用 2 楼 jiftlixu 的回复:
Quote: 引用 1 楼 ACMAIN_CHM 的回复:

少了主键定义。

为什么会这样呢,怎么才能从phpMyAdmin导出的脚本可以从MySQL workbench导入。
导出MySQL 版本5.0 目标MySQL 版本5.6

确实是兼容性导致的问题,在5.0不需要innodb的表的自增列一定要主键,而现在是一定要主键了
mysql> create table tt(i int auto_increment ) engine = innodb;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

mysql> create table tt(i int auto_increment primary key) engine = innodb;
Query OK, 0 rows affected (3.50 sec)


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明phpMyAdmin导出的数据库备份导到MySQL workbench失败
喜欢 (0)
[1034331897@qq.com]
分享 (0)