mysql dump 部分数据库,mysqldump部分数据库

I recently decided to switch the company through which i get my hosting, so to move my old db into my new db, i have been trying to run this:

mysqldump --host=ipaddress --user=username --password=password db_name table_name | mysql -u username -ppassword -h new_url new_db_name

and this seemed to be working fine.. but because my database is so freaking massive, i would get time out errors in the middle of my tables. So i was wondering if there was any easy way to do a mysqldump on just part of my table.

I would assume the work flow will look something like this:

create temp_table

move rows from old_table where id>2,500,000 into temp_table

some how dump the temp table into the new db's table (which has the same name as old_table)

but i'm not exactly sure how to do those steps.

解决方案

Add this --where="id>2500000" at the end of mysqldump command.

In your case the mysqldump command would look like

mysqldump --host=ipaddress \

--user=username \

--password=password \

db_name table_name \

--where="id>2500000

If you dump twice. The second dump will contain table creation info. But next time you want to add the new rows only. So for second dump add --no-create-info option in mysqldump command line.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值