数码资讯
将纯IP数据导入MySQL的方法的3个步骤
先决条件:您将使用VI。很明显本文是在Linux下测试的。本文使用了MySQL命令行工具。如果你不,你应该能够使用phpMyAdmin。 第一步:下载纯真IP数据,将存储在ip.txt。 详细说明:这一步不需要详细解释。如果你没有这一步,你不必在下面看它。 第二步:与VI编辑ip.txt # VI
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
先决条件:您将使用VI。很明显本文是在Linux下测试的。本文使用了MySQL命令行工具。如果你不,你应该能够使用phpMyAdmin。
第一步:下载纯真IP数据,将存储在ip.txt。
详细说明:这一步不需要详细解释。如果你没有这一步,你不必在下面看它。
第二步:与VI编辑ip.txt
# VI ip.txt
在vi接口下输入以下命令:
:%s / / / +;
共有3个重复输入。
支取存款:
:wq
Detailed explanation: ip.txt has 4 columns.It's the starting IP, the end of the IP, the area, the explanation.Unequal space between columns is used between columns.In order to enter this text file into mysql, you need to process these spaces.But only the space in the first 3 columns can be processed, and the space in the last column should be retained.The input command in VI means that the first and its continuous space is replaced with a character ';'.
%s代表全局搜索替换。
第三步:导入mysql
创建MySQL表
复制代码代码如下所示:
创建表IPS。IP
` ip_start ` varchar(16)不为空,
`ip_end` VARCHAR (16) NULL,
`区` varchar(128)空,
`评论` varchar(512)空
MyISAM引擎=)
为了避免随机码,该区域和评论领域gbk_chinese_ci整理设置
进口IP表从ip.txt的IP地址数据库
# mysqlimport - P -地方-删除-场=密码的IPS ip.txt终止;
完成它!
详细说明:mysqlimport可以文本文件导入到数据库表中。前提是,表的名称为文本文件名相同,而表字段对应的文本文件。
字段终止于=;意思是字段被使用;分开。
-删除意味着如果表已经存在,导入前清空表中的数据将被引入。
第一步:下载纯真IP数据,将存储在ip.txt。
详细说明:这一步不需要详细解释。如果你没有这一步,你不必在下面看它。
第二步:与VI编辑ip.txt
# VI ip.txt
在vi接口下输入以下命令:
:%s / / / +;
共有3个重复输入。
支取存款:
:wq
Detailed explanation: ip.txt has 4 columns.It's the starting IP, the end of the IP, the area, the explanation.Unequal space between columns is used between columns.In order to enter this text file into mysql, you need to process these spaces.But only the space in the first 3 columns can be processed, and the space in the last column should be retained.The input command in VI means that the first and its continuous space is replaced with a character ';'.
%s代表全局搜索替换。
第三步:导入mysql
创建MySQL表
复制代码代码如下所示:
创建表IPS。IP
` ip_start ` varchar(16)不为空,
`ip_end` VARCHAR (16) NULL,
`区` varchar(128)空,
`评论` varchar(512)空
MyISAM引擎=)
为了避免随机码,该区域和评论领域gbk_chinese_ci整理设置
进口IP表从ip.txt的IP地址数据库
# mysqlimport - P -地方-删除-场=密码的IPS ip.txt终止;
完成它!
详细说明:mysqlimport可以文本文件导入到数据库表中。前提是,表的名称为文本文件名相同,而表字段对应的文本文件。
字段终止于=;意思是字段被使用;分开。
-删除意味着如果表已经存在,导入前清空表中的数据将被引入。
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。