导出数据库数据

近期接到需求,导出百万级数据库数据,因为阿里云数据库是免费版,导出有限制,所以得用shell导出

1. 数据准备

INSERT into articles(title,subhead,type,slug,content,thumb_img,seo_title,seo_description) SELECT title,subhead,type,slug,content,thumb_img,seo_title,seo_description from articles

表信息

CREATE TABLE `articles` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `subhead` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT '/' COMMENT '跳转地址',
  `type` int(4) DEFAULT NULL,
  `slug` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '链接显示',
  `is_del` tinyint(4) DEFAULT NULL,
  `content` text COLLATE utf8_unicode_ci,
  `thumb_img` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `seo_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `seo_keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `seo_description` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `sort` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

导出数据到csv

mysqldump -uroot -p wxshop articles> shunde.csv
[root@localhost ~]# ll
总用量 343300
-rw-------. 1 root root      1523 2月   3 19:42 anaconda-ks.cfg
-rw-r--r--. 1 root root      1551 2月   3 11:48 initial-setup-ks.cfg
drwxr-xr-x  9 root root       233 3月   1 08:51 ncov
-rw-r--r--  1 root root       315 3月   4 13:52 p.json
drwxr-xr-x  4 root root        35 4月   3 18:44 Playground
-rw-r--r--  1 root root 351524740 6月   7 09:42 shunde.csv
drwxr-xr-x  3 root root        23 6月   5 09:55 var

文件分割用splist

split -n 500000 shunde.csv
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值