mysql导出查询结果到csv,同时将此csv导入到myql
1.查看是否打开导出功能;
sql:SHOW VARIABLES LIKE "secure_file_priv";
1. value值为NULL,表示没有权限,需要修改文件:liunx下:/etc/my.conf,修改 [mysqld] 下的 secure_file_priv,
需要重启数据库,命令:关闭数据库:service mysqld stop,启动数据库: service mysqld start
2. value值为空,表示全目录
3. value值为特定的目录,则表示导出为该目录底下
2.导出csv命令:SELECT * from dd where a =a into outfile '/data/sql/dd.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n';注需要注意文件的访问权限,建议修改权限为777
3.导出mysql命令:load data infile '/data/sql/dd.csv' into table table_name fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n';