MySQL · 数据转移

背景

北京亦庄机房,MySQL 数据库服务器

主:10.159.39.238

从:10.159.39.239

操作

  • 修改表名
1
rename table xx to xx_bak;
  • 将表数据插入到另外一张表
1
2
3
4
5
6
7
8
9
10
11
12
lock tables haier_user_clientsso_log read;
show open tables where in_use > 0;

insert INTO haier_user_clientsso_log_bak select * FROM haier_user_clientsso_log WHERE id > 20085299;

rename table haier_user_clientsso_log haier_user_clientsso_log_copy;
rename table user.haier_user_clientsso_log_bak haier_user_clientsso_log;

unlock tables;
show open tables where in_use > 0;

select count(*) from haier_user_clientsso_log WHERE id > 20085299;