①批量导出
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=""
本文介绍如何使用SQL语句进行MySQL数据库的数据批量导出和导入操作,并提供了具体的示例代码。文中还讲解了如何通过修改my.ini配置文件来支持自定义文件路径的导入。
1679

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



