先导出数据
mysql> select * from timer_gps_posinfo where time>'2017-01-01 00:00' and time <'2017-01-02 00:00' into outfile '/home/posinfo.txt' fields terminated by ',';报错:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
解决:两种方法
1.使用
mysql>SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.00 sec)查看授权路径。
2.禁用secure-file-priv可通过修改配置文件生效。
再试
mysql> select * from timer_gps_posinfo where time>'2017-01-01 00:00' and time <'2017-01-02 00:00' into outfile '/var/lib/mysql-files/posinfo.txt' fields terminated by ',';
Query OK, 4532130 rows affected (16.18 sec)成功导出,用时16秒。
同一台机器,起了个docker-mysql,在新mysql中建立空数据库和表结
使用
mysql> load data infile '/var/lib/mysql-files/posinfo.txt' into table timer_gps_posinfo fields terminated by ',';
Query OK, 4532130 rows affected (17.28 sec)
Records: 4532130 Deleted: 0 Skipped: 0 Warnings: 0导入完成。
转载于:https://blog.51cto.com/diaozhuan/1890406
本文介绍了解决MySQL因--secure-file-priv选项导致无法导出数据的问题,并提供了两种解决方案:调整导出路径至授权目录及修改配置文件禁用此选项。同时展示了数据导出及导入的具体操作。
839

被折叠的 条评论
为什么被折叠?



