使用mysqldump导出数据

/usr/bin/mysqldump --single-transaction -B employees -S /data/mysql/mysql.sock -uroot -p > dump.sql

ob使用source加载

obclient -P2883 -h 192.168.56.20 -uroot@mq_t1 -A

校验数据

使用统计信息

两个数据库收集统计信息的命令相同

收集统计信息

analyze table employees.departments;
analyze table employees.dept_emp;
analyze table employees.dept_manager;
analyze table employees.employees;
analyze table employees.salaries;
analyze table employees.titles;
  • mysql查询数据
mysql>  select TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,TABLE_ROWS from information_schema.TABLES where TABLE_SCHEMA='employees';
+--------------+----------------------+------------+------------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | TABLE_ROWS |
+--------------+----------------------+------------+------------+
| employees | current_dept_emp | VIEW | NULL |
| employees | departments | BASE TABLE | 9 |
| employees | dept_emp | BASE TABLE | 331143 |
| employees | dept_emp_latest_date | VIEW | NULL |
| employees | dept_manager | BASE TABLE | 24 |
| employees | employees | BASE TABLE | 291715 |
| employees | salaries | BASE TABLE | 2844535 |
| employees | titles | BASE TABLE | 440956 |
+--------------+----------------------+------------+------------+
8 rows in set (0.00 sec)
  • ob查询数据
obclient [information_schema]> select TABLE_SCHEMA,TABLE_NAME,TABLE_ROWS from information_schema.TABLES where TABLE_SCHEMA='employees';
+--------------+--------------+------------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_ROWS |
+--------------+--------------+------------+
| employees | departments | 9 |
| employees | dept_emp | 331603 |
| employees | dept_manager | 24 |
| employees | employees | 300024 |
| employees | salaries | 2844535 |
| employees | titles | 443308 |
+--------------+--------------+------------+
6 rows in set (0.008 sec)
  • 总结

    • mysql中有两个对象是视图,视图没有导入
    • 导入过程中报错"ERROR 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'",将导出文件中的"COLLATE=utf8mb4_0900_ai_ci"删除即可解决.
    • 使用统计信息对数据的方式不够准确,如果数据量比较小,通过count(*)也不是不可以.

使用count(*)

  • mysql库
mysql> select count(*) from  employees.departments;
+----------+
| count(*) |
+----------+
| 9 |
+----------+
1 row in set (0.04 sec) mysql> select count(*) from employees.dept_emp;
+----------+
| count(*) |
+----------+
| 331603 |
+----------+
1 row in set (0.04 sec) mysql> select count(*) from employees.dept_manager;
+----------+
| count(*) |
+----------+
| 24 |
+----------+
1 row in set (0.00 sec) mysql> select count(*) from employees.employees;
+----------+
| count(*) |
+----------+
| 300024 |
+----------+
1 row in set (0.07 sec) mysql> select count(*) from employees.salaries;
+----------+
| count(*) |
+----------+
| 2844047 |
+----------+
1 row in set (0.46 sec) mysql> select count(*) from employees.titles;
+----------+
| count(*) |
+----------+
| 443308 |
+----------+
1 row in set (0.09 sec)
  • ob库
obclient [information_schema]> select count(*) from  employees.departments;
+----------+
| count(*) |
+----------+
| 9 |
+----------+
1 row in set (0.108 sec) obclient [information_schema]> select count(*) from employees.dept_emp;
+----------+
| count(*) |
+----------+
| 331603 |
+----------+
1 row in set (0.160 sec) obclient [information_schema]> select count(*) from employees.dept_manager;
+----------+
| count(*) |
+----------+
| 24 |
+----------+
1 row in set (0.024 sec) obclient [information_schema]> select count(*) from employees.employees;
+----------+
| count(*) |
+----------+
| 300024 |
+----------+
1 row in set (0.341 sec) obclient [information_schema]> select count(*) from employees.salaries; +----------+
| count(*) |
+----------+
| 2844047 |
+----------+
1 row in set (1.989 sec) obclient [information_schema]> select count(*) from employees.titles;
+----------+
| count(*) |
+----------+
| 443308 |
+----------+
1 row in set (0.212 sec)

mysqldump从mysql迁移数据到OceanBase的更多相关文章

  1. mysql 迁移数据

    一.导出导入所有数据库的数据 1.导出 mysqldump -u root -p123456 --all-databases > all.sql 2.导入 mysql -u root -p123 ...

  2. mysql学习(4)-mysqldump备份和恢复数据

    背景 最近在公司做数据迁移方面的工作,使用mysql数据库在测试环境模拟数据迁移,在迁移测试的过程中需要做数据备份和恢复 mysql数据备份和恢复比较简单,可以选择mysqldump工具,这里简单提一 ...

  3. mysql迁移-----拷贝mysql目录/load data/mysqldump/into outfile

    摘要:本文简单介绍了mysql的三种备份,并解答了有一些实际备份中会遇到的问题.备份恢复有三种(除了用从库做备份之外), 直接拷贝文件,load data 和 mysqldump命令.少量数据使用my ...

  4. MySQL大数据迁移备份

    MySQL迁移通常使用的有三种方法:   1.数据库直接导出,拷贝文件到新服务器,在新服务器上导入. 2.使用第三方迁移工具. 3.数据文件和库表结构文件直接拷贝到新服务器,挂载到同样配置的MySQL ...

  5. 将数据从MySQL迁移到Oracle的注意事项

    将数据从MySQL迁移到Oracle的注意事项1.自动增长的数据类型处理MYSQL有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值.ORACLE没有自动增长的数据类型,需要建立一个自动 ...

  6. SQL Server 迁移数据到MySQL

    一.背景 由于项目开始时候使用的数据库是SQL Server,后来把存储的数据库调整为MySQL,所以需要把SQL Server的数据转移到MySQL:由于涉及的表比较多,所以想在MySQL中生成对应 ...

  7. mysql分库分表,做到永不迁移数据和避免热点

    作者:老顾聊技术   搜云库技术团队  来源:https://www.toutiao.com/i6677459303055491597 一.前言 中大型项目中,一旦遇到数据量比较大,小伙伴应该都知道就 ...

  8. mysql第一天【mysqldump导出数据和mysql导入数据】

    1.使用mysqldump导出数据到本地sql文件 在mysql>bin下执行: 例如: mysqldump -hrm-2ze8mpi5i65429l1qvo.mysql.rds.aliyunc ...

  9. Django项目的创建与介绍.应用的创建与介绍.启动项目.pycharm创建启动项目.生命周期.三件套.静态文件.请求及数据.配置Mysql完成数据迁移.单表ORM记录的增删改查

    一.Django项目的创建与介绍 ''' 安装Django #在cmd中输入pip3 #出现这个错误Fatal error in launcher: Unable to create process ...

  10. 数据从mysql迁移至oracle时知识点记录(一)

    最近在做数据的迁移,再将数据从mysql迁移至oracle时,部分sql语句进行了修改,在此对部分知识点进行记录: 参考资料:https://dev.mysql.com/doc/refman/5.5/ ...

随机推荐

  1. brew之加速

    有没有出现这种场景:使用brew install 安装程序,一直卡在brew updating,这可能是使用着默认的github镜像源导致,那么我们就需要将其切换到国内 1.镜像切换(推荐中科大) 1 ...

  2. Flink 1.10中idea运行出错invalid flag

    今日好奇,下载Flink 1.10的源码在本机玩一玩. 将工程按照正常流程导入IDEA后,运行flink-examples中的demo竟出现如下错误 Error:java: invalid flag: ...

  3. MYSQL8给新用户grant权限报错的解决方法

    ​MYSQL8用客户端创建用户,无法grant,报错:Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) . 解 ...

  4. 【C#】【Cookie】Cookie设置与读取

    依赖 using System.Web; 设置Cookie 1.新建Cookie对象 HttpCookie cookie = new HttpCookie("UserInfo"); ...

  5. IDEA利用阿里云插件部署Springboot项目

    下载插件 搜索 Alibaba Cloud Toolkit 插件,并安装. IDEA增加Run/Debug Configurations Add New Configuration - Deploy ...

  6. 开源轻量级 IM 框架 MobileIMSDK v6.1.2 发布!

    一.更新内容简介 本次更新为次要版本更新,进行了若干优化(更新历史详见:码云 Release Nodes).可能是市面上唯一同时支持 UDP+TCP+WebSocket 三种协议的同类开源IM框架. ...

  7. 在 .NET 中使用 Tesseract 识别图片文字

    1. 什么是 Tesseract Tesseract 是一个强大的字符识别 (OCR) 工具.它最初由 HP 发布,现在由 Google 和学术社区共同维护和开发. Tesseract 支持多种语言和 ...

  8. Solution Set -「LOCAL」冲刺省选 Round XXVII

    \(\mathscr{Summary}\)   还行,B 题挺不错,C 题就省选来说有点水(? \(\mathscr{Solution}\) \(\mathscr{A-}\) 分裂   初始时,你有一 ...

  9. MS Speech/ azure

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. Spring Cloud Alibaba实战,从微服务架构到基本服务配置

    https://blog.csdn.net/itcast_cn/article/details/124558887 Spring Cloud Alibaba 实战 1目标理解什么是微服务架构理解什么是 ...