码迷,mamicode.com
首页 > 数据库 > 详细

MySQL SELECT xxx INTO OUTFILE用法

时间:2019-01-30 07:32:13      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:导出数据   rmi   pre   \n   optional   rom   not   mys   val   

1、导出数据报错 mysql> SELECT * INTO OUTFILE ‘/tmp/t.txt‘ FIELDS TERMINATED BY ‘,‘ OPTIONALLY ENCLOSED BY ‘"‘ LINES TERMINATED BY ‘\n‘ FROM t; ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement mysql> show variables like ‘%secure%‘; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | require_secure_transport | OFF | | secure_auth | ON | | secure_file_priv | NULL | +--------------------------+-------+ 3 rows in set (0.01 sec) mysql> 2、解决方法,需要重启数据库 [mysqld] secure_file_priv=‘‘ 3、重新导出,OK mysql> SELECT * INTO OUTFILE ‘/tmp/t.txt‘ FIELDS TERMINATED BY ‘,‘ OPTIONALLY ENCLOSED BY ‘"‘ LINES TERMINATED BY ‘\n‘ FROM t; Query OK, 2 rows affected (0.00 sec) mysql> 4、查看验证 [mysql@roidb01 ~]$ cat /tmp/t.txt 1,"a" 2,"b" [mysql@roidb01 ~]$ 5、导入成功 mysql> LOAD DATA INFILE "/tmp/t.txt" INTO TABLE trsids.t FIELDS TERMINATED BY ‘,‘ OPTIONALLY ENCLOSED BY ‘"‘ LINES TERMINATED BY ‘\n‘ -> ; Query OK, 2 rows affected (0.01 sec) 6、验证数据OK mysql> select * from trsids.t; +------+------+ | id | name | +------+------+ | 1 | a | | 2 | b | | 1 | a | | 2 | b | +------+------+ 4 rows in set (0.00 sec) mysql>

MySQL SELECT xxx INTO OUTFILE用法

标签:导出数据   rmi   pre   \n   optional   rom   not   mys   val   

原文地址:http://blog.51cto.com/roidba/2347762

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!