1、作用:将表中数据导出,不包括表结构 2、语法格式: select * from 表名 into outfile '/路径/文件名' 【fields terminated by ',' 导出字段内容要按照,分割 enclosed by '"' 导出字段内容使用双引号括起 lines terminated by '\r\n' 导出每行数据内容使用\r\n分割 escaped by "*"】指定用*进行转义 fields子句可选,只要使用fields关键字就需要指定以上3个条件至少一个 3、导出文件要求: 导出文件路径目录已存在 目录有777权限 sql操作用户有file权限 mysql --version >5.1 4、导入文件中的数据到新表: 格式:load data infile "路径" [replace/ignore] into table 表名 load data infile "/data/test1/out/0603.sql" replace into table istester_like; 遇到的问题: 1、The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 解决:查看secure-file-priv设置:show variables like ‘%secure%’; null是不能导出,具体路径则只能导出导入到该路径,为空则不做限制可自定义路径 修改mysql配置文件:新增行secure-file-priv="" 重启mysql :service mysqld restart 2、Can't create/write to file 原因:/root目录为root用户的目录,mysql用户组无法访问 解决:修改导出的位置到/data目录下