1、查看本地secure-file-priv变量配置
mysql> show variables like '%secure%';
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | /var/lib/mysql-files/ |
+--------------------------+-----------------------+
3 rows in set (0.02 sec)
可以看到显示出来的secure-file-priv配置是什么路径,此时把文件放到指定路径,再执行导入导出操作即可;
2、进行导出操作
mysql> select * into outfile '/var/lib/mysql-files/test.csv' from test;
Query OK, 7725 rows affected (0.04 sec)
注:
Mysql导入csv文件时报错:ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti on so it cannot exe
原因:mysql导入导出文件只能在secure-file-priv该变量配置的指定路径下的文件才可以导入导出
解决方法:进行上述步骤即可。