注:
MYSQL导入数据出现The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
这个原因其实很简单,是因为在安装MySQL的时候限制了导入与导出的目录权限
只能在规定的目录下才能导入
我们需要通过下面命令查看 secure-file-priv 当前的值是什么
mysql> show variables like '%secure%';
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| require_secure_transport | OFF |
| secure_file_priv | /var/lib/mysql-files/ |
+--------------------------+-----------------------+
2 rows in set (0.00 sec)
mysql>
一、导出到csv
通过mysql客户端shell连接到服务器,选择使用的数据库,输入sql代码:
select * from test_info
into outfile '/tmp/test.csv'
fields terminate