资料给的icake.sql根本导不进去,直接用命令符导不了,一条条导也不行,用idea导也不行

资料给的icake.sql根本导不进去,直接用命令符导不了,一条条导也不行,用idea导也不行

[2019-11-18 17:08:14] Run E:\自学\数据库\项目商品信息管理\静态页面\icake.sql

[2019-11-18 17:08:14] Connecting to localhost...

[2019-11-18 17:08:14] Using batch mode (1000 insert/update/delete statements max)

drop database if exists icake

[2019-11-18 17:08:14] 3 row(s) affected in 34 ms

create database icake

[2019-11-18 17:08:14] 1 row(s) affected in 3 ms

use icake

[2019-11-18 17:08:14] 0 row(s) affected in 1 ms

drop table if exists account

[2019-11-18 17:08:14] 0 row(s) affected in 1 ms

drop table if exists cake

[2019-11-18 17:08:14] 0 row(s) affected in 2 ms

drop table if exists catalog

[2019-11-18 17:08:14] 0 row(s) affected in 1 ms

create table account

(

id                   int not null auto_increment,

account              varchar(20),

password             varchar(20),

nick_name            varchar(20),

primary key (id)

)

[2019-11-18 17:08:14] 0 row(s) affected in 15 ms

create table cake

(

id                   int not null auto_increment,

title                varchar(20),

cid                  int,

image_path           varchar(100),

price                double,

taste                varchar...

[2019-11-18 17:08:14] 0 row(s) affected in 14 ms

create table catalog

(

id                   int not null auto_increment,

title                varchar(20),

pid                  int,

info                 varchar(100),

primary key (id)

)

[2019-11-18 17:08:14] 0 row(s) affected in 12 ms

alter table cake add constraint FK_Reference_1 foreign key (cid)

references catalog (id) on delete restrict on update restrict

[2019-11-18 17:08:14] 0 row(s) affected in 31 ms

alter table catalog add constraint FK_Reference_2 foreign key (pid)

references catalog (id) on delete restrict on update restrict

[2019-11-18 17:08:14] 0 row(s) affected in 33 ms

insert into account(id,account,password,nick_name) values(10000,'admin','admin','管理员')

........

[2019-11-18 17:08:14] [HY000][1366] Incorrect string value: '\xE6\xB7\xB1\xE8\x89\xBE...' for column 'title' at row 1

[2019-11-18 17:08:14] Summary: 84 of 84 statements executed, 73 failed in 349 ms (7219 symbols in file)





建表后面都没有ENGINE=INNODB  CHARSET=UTF8;  把这个加上去也不行

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕阿莹 2019-11-18 19:25:05

同学你好,请问同学使用的是什么工具呢?老师这边导入显示是没问题的:

http://img1.sycdn.imooc.com//climg/5dd27cf809134c7f03700272.jpg

http://img1.sycdn.imooc.com//climg/5dd27d08099032a103700269.jpg

http://img1.sycdn.imooc.com//climg/5dd27d210918c68c01770103.jpg

使用直接粘贴全选的方式也可以成功运行的:

http://img1.sycdn.imooc.com//climg/5dd27f2b0937263a06050898.jpg

看同学的报错是外键的报错,请问同学之前是否有这个数据库或者表,如果有的话,建议删除后重新创建一下。

老师用的工具是sqlYog。

建议同学如果之前有这个数据库,删除这个库重新导入一下试试。


如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

  • 提问者 松糕 #1
    用idea里面的database导入,不行。然后我直接将里面的内容复制导命令符里面运行也不行
    2019-11-18 20:02:40
  • 提问者 松糕 #2
    之前没有这个数据库,他这个sql文件开头不是写了drop databse if exists icake;这个指令是不是存在这个icake数据库就会删除呢
    2019-11-18 20:04:53
  • 提问者 松糕 #3
    百度了方法解决了这个问题
    2019-11-18 20:37:28
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师