MySql 中导入sql文件

时间:2022-12-27 06:41:41

使用控制台执行:


D:\mysql-5.6.26-winx64\bin>mysql -uroot -proot

mysql> source C:\Users\Administrator\Desktop\seckill\src\schema.sql
Database changed
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> drop table  if exists seckill_user;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> source C:\Users\Administrator\Desktop\seckill\src\schema.sql
Database changed
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.06 sec)

Query OK, 0 rows affected (0.04 sec)

Query OK, 4 rows affected (0.01 sec)
Records: 4  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.03 sec)

mysql> drop table if exists `user`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table `user`(
    ->  `id` bigint(20) not null auto_increment,
    ->  `password` varchar(45) not null,
    ->  `name` varchar(45) not null,
    ->  `login_time` datetime not null,
    ->  `create_time` datetime not null,
    ->  `update_time` datetime not null,
    ->  primary key(`id`),
    ->  unique key `user_name_UNIQUE`(`name`)
    -> )engine=InnoDB default charset=utf8;
Query OK, 0 rows affected (0.07 sec)

mysql>
mysql>
mysql> create table `order_basic`(
    ->  `id` bigint(20) unsigned not null auto_increment,
    ->  `user_id` bigint(20) unsigned not null comment '用户id',
    ->  `order_status` int(4) not null comment '订单状态',
    ->  `total_price` int(11) not null comment '订单总价',
    ->  `total_settlement_price` int(11) not null comment '订单结算总价',
    ->  `address` mediumtext comment '收货地址',
    ->  `receiver` varchar(128) not null comment '收件人',
    ->  `phone` varchar(20) not null comment '电话',
    ->  `pay_type` int(2) default '0' comment '支付方式:1微信 2支付宝 3货到付款
',
    ->  `create_time` datetime not null,
    ->  `update_time` datetime not null,
    ->  primary key(`id`),
    ->  key `order_user_INDEX` (`user_id`)
    -> )engine=InnoDB default charset=utf8;
Query OK, 0 rows affected (0.07 sec)

mysql>