当前位置:Gxlcms > 数据库问题 > MySQL8.0实验-从本地文件导入数据

MySQL8.0实验-从本地文件导入数据

时间:2021-07-01 10:21:17 帮助过:33人阅读

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; 

 

完成后即可得到结果:

技术图片

MySQL8.0实验-从本地文件导入数据

标签:font   .com   global   comm   原因   birt   arc   with   实现   

人气教程排行