MySQL: 数据的导入

数据的导入

方法1 :图形工具

MySQL: 数据的导入_第1张图片

方法2: SQL 语句

load data infile 文件路经 into table

fields terminated by ' ' lines terminated by '\r\n'

空格: fields terminated by ' \t'

逗号:fields terminated by ', '

in windown, the file address is ,e.g D:\Study\MySQL, here should be ' D:/Study/MySQL'

csv format 

 去掉第一行标题行

load data infile 'D:/stuScore_data.csv'
into table StuScore FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

保留第一行标题行

load data infile 'D:/stuScore.csv'
into table StuScore2 fields terminated by ',' enclosed by '"'  ignore 1 lines;

text format:

load data infile 'D:/Python/StuInfo_import.txt' into table StuInfo fields terminated by ',' lines terminated by '\r\n';

 

错误:1290

 

****错误:1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 

处理方式:修改mysql配置文件my.ini中secure-file-priv的值,为空任意文件目录导出,配置目录为指定目录导入导出。

如何找配置文件my.ini?

win10,直接查找 服务 ->属性

MySQL: 数据的导入_第2张图片

MySQL: 数据的导入_第3张图片

MySQL: 数据的导入_第4张图片

MySQL: 数据的导入_第5张图片

 


 

 

 

 

 

 

 

 

你可能感兴趣的:(MySQL)