mysqldump部分数据库 [英] mysqldump partial database
问题描述
我最近决定切换公司,我通过它,我得到我的托管,所以将我的旧数据库移动到我的新数据库,我一直试图运行这:
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
这似乎工作正常..我的数据库是如此惊人的大,我会得到时间错误在我的表中间。所以我想知道是否有任何简单的方法做一个 mysqldump
只是我的表的一部分。
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)
$ b $
but i'm not exactly sure how to do those steps.
推荐答案
添加此 --where =id> 2500000
在 mysqldump
MySQL 5.1参考手册
Add this --where="id>2500000"
at the end of mysqldump
command. MySQL 5.1 Reference Manual
在您的情况下, mysqldump
命令看起来像
In your case the mysqldump
command would look like
mysqldump --host=ipaddress \
--user=username \
--password=password \
db_name table_name \
--where="id>2500000
如果转储两次,因此对于第二个转储,在 mysqldump中添加
命令行。 - no-create-info
选项
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.
这篇关于mysqldump部分数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!