阅读量:1
遇见权限问题1: cat /etc/my.cnf加入
[mysqld]
secure_file_priv = ""
遇见目录错误2:因为 MySQL 服务器没有权限在根目录下创建文件。你可以尝试将文件导出到一个 MySQL 服务器有权限写入的目录下,例如 MySQL 数据目录或 /tmp目录。sudo chmod 755 /path/to/your/dir
SELECT * FROM t_teacher
INTO OUTFILE '/tmp/a.txt'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
LOAD DATA INFILE '/tmp/a.txt'
INTO TABLE t_teacher
IGNORE 1 LINES
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
注:
/path/to/your/file.txt
是文本文件的路径。your_table_name
是你想导入数据的表名。FIELDS TERMINATED BY ','
表示字段用逗号分隔。ENC BY '"'
表示每个字段值用双引号包围。LINES TERMINATED BY '\n'
表示每行用换行符结束。