标签:base mamicode bow info glob slim and bsp lob
按照mysql官方文档指示下
创建数据库和表:
mysql> create database menagrie;
然后创建表:
1 mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), 2 species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
然后将以下数据写入一个pet.txt文本中:
Fluffy Harold cat f 1993-02-04 \N
Claws Gwen cat m 1994-03-17 \N
Buffy Harold dog f 1989-05-13 \N
Fang Benny dog m 1990-08-27 \N
Bowser Diane dog m 1979-08-31 1995-07-29
Chirpy Gwen bird f 1998-09-11 \N
Whistler Gwen bird \N 1997-12-09 \N
Slim Benny snake m 1996-04-29 \N
使用以下命令实现导入数据库:
1 mysql> LOAD DATA LOCAL INFILE ‘/path/pet.txt‘ INTO TABLE pet;
途中遇到了一个问题:
百度了一下此问题:
出现错误显示 ERROR 1148 (42000): The used command is not allowed with this MySQL version
原因:local_infile变量处于OFF 需要手动将其置于ON
1 mysql> SET GLOBAL local_infile=1;
完成后再导入数据即可:
完成后即可得到结果:
标签:base mamicode bow info glob slim and bsp lob
原文地址:https://www.cnblogs.com/dpqq/p/10713845.html