mysql数据库的批量文件导入

mysql -uroot -p123456

导出报错:

mysql> select * from bdastat.stat into outfile 'test.txt';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

修改my.ini文件

[mysqld]    
secure_file_priv="D:\TEST"  

重启mysql

net stop mysql;net start mysql

登陆mysql查看

mysql> show variables like '%secur%';
+--------------------------+----------+
| Variable_name            | Value    |
+--------------------------+----------+
| require_secure_transport | OFF      |
| secure_auth              | ON       |
| secure_file_priv         | D:\TEST\ |
+--------------------------+----------+

然后再次执行就可以了

mysql> select * from bdastat.stat into outfile 'd:/test/test.txt';
Query OK, 801 rows affected (0.01 sec)

 

1、创建表,这里用的是TEXT字段类型

CREATE TABLE bdastat.`stat` (
  `field1` text,
  `field2` text,
  `field3` text,
  `field4` text,
  `field5` text,
  `field6` text,
  `field7` text,
  `field8` text,
  `field9` text,
  `field10` text,
  `field11` text,
  `field12` text,
  `field13` text,
  `field14` text,
  `field15` text,
  `field16` text,
  `field17` text,
  `field18` text,
  `field19` text,
  `field20` text,
  `field21` text,
  `field22` text,
  `field23` text,
  `field24` text,
  `field25` text,
  `field26` text
)

 

load data infile "D:\test\\文件名.txt" into table 表 fields terminated by '|' lines terminated by '\n' ;

mysql> load data infile "D:/TEST/node9.txt" into table bdastat.stat fields terminated by '|';
Query OK, 802 rows affected (0.13 sec)
Records: 802  Deleted: 0  Skipped: 0  Warnings: 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值