mysql 导入导出大文件

mysql导入:

load data  local infile 'C:/Users/Administrator.USER-20190225BY/Desktop/test.csv' 
into table test
fields
terminated by'\t'
lines terminated by'\n'
ignore 1 lines
(xianlu,chepai,shijian,jing,wei)

mysql导出:

select * from mysql.test into outfile 'C:\\Users\\Administrator.USER-20190225BY\\Desktop\\output_test.csv'
fields 
terminated by ','
enclosed by '"'
lines terminated by '\r\n'

导入和导出文件夹最好用:show variables like '%basedir%' 结果的目录。

遇到问题:

Mysql数据库从文件导入或导出到文件,提示The MySQL server is running with the --secure-file-priv option so it cannot execute this statement ,原因及解决方法如下:

一些版本的mysql对通过文件导入导出作了限制,默认不允许,

查看配置,执行mysql命令

SHOW VARIABLES LIKE "secure_file_priv";

如果value值为null,则为禁止,如果有文件夹目录,则只允许改目录下文件(测试子目录也不行),如果为空,则不限制目录;

修改配置可修改mysql配置文件,查看是否有

secure_file_priv = 

这样一行内容,如果没有,则手动添加,

secure_file_priv = /home 

表示限制为/home文件夹

secure_file_priv = 

表示不限制目录,等号一定要有,否则mysql无法启动

修改完配置文件后,重启mysql生效

 参考自:http://blog.sina.com.cn/s/blog_59bba95d0102wspc.html

猜你喜欢

转载自blog.csdn.net/weixin_38383877/article/details/88297405