背景:将大量的历史日志(不能手动打开去查的情况)导入mysql查询相关信息。
1、需要先弄清除每个字段的含义以及sql类型,否则导入时不成功。
2、创建库表
create database ttt;
CREATE TABLE IF NOT EXISTS `check`(
`type` VARCHAR(100) NOT NULL,
`tid` VARCHAR(100) NOT NULL,
`time` DATE,
`gw_ip` VARCHAR(100) NOT NULL,
`eip` VARCHAR(100) NOT NULL,
`in_Bps` int NOT NULL,
`out_Bps` int NOT NULL,
`in_pps` int NOT NULL,
`out_pps` int NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
3、导入数据
# local infile '' 是指定需要导入的本地文件;into table 是指定要导入到哪个表;
# fields terminated by ‘,’ 是指以逗号作为分隔符。
load data local infile 'D:/kevin/check.txt' into table eip_check fields terminated by ',';
4、查看数据
select * from check limit 1;
评论区