Mysql批量匯出與批量匯入
阿新 • • 發佈:2018-12-22
①批量匯出
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=""