Mysql批量导出与批量导入

①批量导出

1)如果想把云服务器上的mysql数据库数据导出到本地 只能使用 客户端语句

在终端使用mysql -u root -p test -e 'SELECT loid FROM ana_customer WHERE localnet_id='101000';' > 101000_loid.txt 将表中数据导出到本地

 2)如果使用Mysql的 CAPI接口 的话 那么只能是同实现同一台机器上的数据导出

char sql[1024]

  sprintf_s(sql,"select * into outfile '%s' fields terminated by '%c'LINES TERMINATED BY '\r\n' from %s ", filepath.c_str(), c, tablename.c_str());

②批量导入

char sql[1024]

char c = '"';
 sprintf_s(sql, "load data local infile'%s' into table %s fields terminated by ',' optionally enclosed by'%c'escaped by'%c'lines terminated by'\r\n'", filepath.c_str(), tablename.c_str(), c, c);

想用sql语句导入到自己定义的文件下 就需要修改mysql的my.ini配置

使 secure-file-priv=""

猜你喜欢

转载自blog.csdn.net/huangwei2014/article/details/82345189