mysql导入.csv文件

1、sql命令

#第一行.csv文件就是你要导入的文件
#第二行就是你要插入的表
#第三行表明数据之间以,号分割
#第四行表示数据以换行结束

ps:下面的是一条sql语句

1 load data infile '.csv文件'   
2 into table `table` 
3 fields terminated by ','
4 lines terminated by '\r\n';

2、当执行语句报错

报错信息如下:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

3、执行如下命令

1 show variables like '%secure%'

4、将要导入的.csv文件到此路径下

我们会看到第三步有一个secure_file_prive参数 其值为/var/lib/mysql-files/ (ps:linux下的路径)将你自己的要导入的.csv文件放到此路径下

5、执行第一步的代码如图(使用的navicate连接工具)

 

posted @ 2019-08-05 14:42  石二南  阅读(1153)  评论(0)    收藏  举报