码迷,mamicode.com
首页 > 其他好文 > 详细

my21_mydumper与myloader使用

时间:2019-01-09 19:29:14      阅读:353      评论:0      收藏:0      [点我收藏+]

标签:delete   记录   重复   ble   create   sele   第一条   str   ati   

-o 参数

如果不使用-o参数,遇到第一个有主键或者唯一约束的数据,则退出当前线程;如果有-o参数,则删除原来的表,创建新表,再插入数据,主键不会发生变化。

** Message: Dropping table or view (if exists) `maell`.`bootrap`
** Message: Creating table `maell`.`bootrap`

 

mysql -uautomng -prootroot -h127.0.0.1
mkdir -p /data/tmp/table
mydumper -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -T test -e -o /data/tmp/table

mysql> select * from test;
+------+--------+---------+------------------------+---------------------+
| tid | tname | test_id | tvalue | CreateTime |
+------+--------+---------+------------------------+---------------------+
| 2 | aaabbb | 3 | 有张有驰有分寸2 | 2018-11-17 21:39:58 |
| 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
| 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
+------+--------+---------+------------------------+---------------------+
3 rows in set (0.00 sec)

删除、更新、插入各一条记录
mysql> delete from test where tid=2;
Query OK, 1 row affected (0.06 sec)

mysql> insert into test (tid,tname) values (1,‘123‘);
Query OK, 1 row affected (0.09 sec)

mysql> update test set tid=4 where tvalue=‘wa ka ka‘;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql> select * from test;
+------+--------+---------+------------------------+---------------------+
| tid | tname | test_id | tvalue | CreateTime |
+------+--------+---------+------------------------+---------------------+
| 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
| 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
| 1 | 123 | 7 | NULL | 2019-01-09 18:55:19 |
+------+--------+---------+------------------------+---------------------+
3 rows in set (0.00 sec)


导入,没有-o参数,默认开启四线程,表存在时重新插入数据,在遇到第一条重复数据时报错并退出当前线程;原有库数据不会发生变化
myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -v 3

# myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -v 3
** Message: 4 threads created
** Message: Creating table `vodb`.`test`

** (myloader:23544): CRITICAL **: Error restoring vodb.test from file vodb.test-schema.sql: Table ‘test‘ already exists
** Message: Thread 1 restoring `vodb`.`test` part 0
** Message: Thread 2 shutting down
** Message: Thread 3 shutting down
** Message: Thread 4 shutting down

** (myloader:23544): CRITICAL **: Error restoring vodb.test from file vodb.test.sql: Duplicate entry ‘4‘ for key ‘PRIMARY‘
** Message: Thread 1 shutting down


-o则是将原来数据清除,然后再插入,与原数据一致
myloader -u automng -p rootroot -h 127.0.0.1 -P 3306 -B vodb -d /data/tmp/table -o -v 3

mysql> select * from test;
+------+--------+---------+------------------------+---------------------+
| tid | tname | test_id | tvalue | CreateTime |
+------+--------+---------+------------------------+---------------------+
| 2 | aaabbb | 3 | 有张有驰有分寸2 | 2018-11-17 21:39:58 |
| 3 | aaabbb | 4 | 有张有驰有分寸3 | 2018-11-17 21:39:58 |
| 4 | aaabbb | 5 | 有张有驰有分寸4 | 2018-11-17 21:39:58 |
+------+--------+---------+------------------------+---------------------+
3 rows in set (0.00 sec)

 

my21_mydumper与myloader使用

标签:delete   记录   重复   ble   create   sele   第一条   str   ati   

原文地址:https://www.cnblogs.com/perfei/p/10246293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!